popup->triggered().connect(boost::bind(&Home::handlePopup, this,
WString::fromUTF8(l.path_)));
gives me this Error:
/usr/include/boost/bind/bind.hpp:313: error: no match for call to
'(boost::_mfi::mf1<void, Home, Wt::WString*>) (Home*&, Wt::WString&)'
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);

It looks like the Template does not support Wt::WString, not sure how to
get this to work with a mouse event or bool signal, do you know of a
work around for this problem?

Is it possible to make WMenu work as a popup?

On Fri, 2014-02-21 at 10:53 +0100, Wim Dumon wrote:
> Hi,
> 
> 
> 
> WSignalMapper is deprecated, we recommend to use boost::bind instead.
> I modified the widget gallery so that it won't recommend it anymore.
> This is the alternative using boost::bind().
> 
> 
> ... 
> 
>     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_));
>         popup->triggered().connect(boost::bind(&Home::handlePopup, this, 
> WString::fromUTF8(l.path_));
>     }
> ...
> void Home::handlePopup(const 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);
>     }
> }
> 
> 
> Best regards,
> Wim.
> 
> 
> 
> 
> 
> 2014-02-21 7:00 GMT+01:00 Jeffrey Scott Flesher Gmail
> <jeffrey.scott.fles...@gmail.com>:
> 
>         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
>         witty-interest@lists.sourceforge.net
>         https://lists.sourceforge.net/lists/listinfo/witty-interest
>         
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> 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
> witty-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------------------------
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
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to