I could not find an example or any function to do this, but what I want
is for the dropdown example in Navigation to send an internal path
change, so I can use it to change languages; this did not work, it gets
called for every menu item, no idea why, can anyone help?
The documentation says You can use a WSignalMapper to bind extra data
with an item's WMenuItem.triggered signal, and handle them in a single
slot. 
http://jwt.emweb.be/jwt-gallery/gallery/navigation/popup-menu
my guess is that popup->triggered() is the event for all of them, and
not just the one I need, so how do you reference the addItem?

...

    for (unsigned i = 0; i < languages.size(); ++i)
    {
        // Get Languages
        const Lang& l = languages[i];
        // Add Popup Item with Description.
        popup->addItem(WString::fromUTF8(l.longDescription_));
        // Create Signal Mapper
        Wt::WSignalMapper<Wt::WString*> *myMap = new 
Wt::WSignalMapper<Wt::WString*>(popup);
        // Connect to callback function
        myMap->mapped().connect(this, &Home::handlePopup);
        // Connect on triggered to path
        myMap->mapConnect(popup->triggered(), new 
WString(WString::fromUTF8(l.path_)));
    }
...
void Home::handlePopup(Wt::WString * data)
{
    Wt::log("notice") << "(data: " << *data << ")";
    Wt::WApplication* const app = wApp;
    if (*data == "/") // English
    {
        Wt::log("notice") << "(set language to English: " << ")";
        app->setInternalPath("/", true);
    }
    else if (*data == "/cn/") // 中文 (Chinese)
    {
        Wt::log("notice") << "(set language to Chinese: " << ")";
        app->setInternalPath("/cn", true);
    }
    else if (*data == "/ru/") // Русский (Russian)
    {
        Wt::log("notice") << "(set language to Russian: " << ")";
        app->setInternalPath("/ru", true);
    }
}




------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to