[sword-devel] Getting entry by key for a lexicon module.

Troy A. Griffitts scribe at crosswire.org
Mon Jan 3 14:21:41 EST 2022


Hi David. You should skip the attempt to parse a verse list. Something 
simple like:

module->setKeyText("Moses");
SWBuf entryBody = module->renderText();
SWBuf entryKey = module->getKeyText();

Notice the renderText call before the getKeyText call. renderText will 
"snap" the requested key to the closest entry in the module. If you swap 
the order, the getKeyText will simply return whatever you set, which 
isn't too useful.

It's up to you to determine if the snapped entry is of use to your user 
if it is not exactly what you requested. In my frontends, I usually snap 
to the closest entry and then -- the module a couple times and then loop 
over 5 entries, which results in showing the snapped entry and 2 entries 
before and after, and I usually show this as the user types, so they can 
visually see the nearest entries so far, allowing them to navigate to 
their desired entry or see that nothing matches very well. Here is an 
example:

https://crosswire.org/study/examples/suggest.jsp?mod=Easton

Hope this is helpful.

Troy



On January 3, 2022 11:29:50 AM MST, "David "Judah's Shadow" Blue" 
<yudahsshadow at gmx.com> wrote:

    Ok. So I'm looking at getting a specific key for a lexdict module. I tried the
    same as I do for bibles/commentaries.

    sword::ListKey refRange;

    refRange = key.parseVerseList(reference.c_str(), key, true);
    for(refRange = sword::TOP; !refRange.popError(); refRange++) {
             module->setKey(refRange);
             text += " ";
             text += module->getKeyText();
             text += " ";
             text += module->stripText();
    }

    But I can only seem to get the last entry of the module.. I can't find any
    examples to go by for what I am doing wrong or how to do a lexicon with a
    single key.
    ------------------------------------------------------------------------
    sword-devel mailing list:sword-devel at crosswire.org
    http://crosswire.org/mailman/listinfo/sword-devel
    Instructions to unsubscribe/change your settings at above page
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20220103/fb7776f1/attachment.html>


More information about the sword-devel mailing list