2014/1/3 Wim Dumon <w...@emweb.be>

> Hello Dmitriy,
>
> I'm confused about how you mix menus and popupmenus in this example. Can
> you explain what you want to do?
>
> BR,
> Wim.
>
>
>
> 2013/12/31 Dmitriy Igrishin <dmit...@gmail.com>
>
>> Hey Wim,
>>
>>
>> 2013/12/31 Wim Dumon <w...@emweb.be>
>>
>>> Hello Dmitriy,
>>>
>>> Thank you for reporting the WMenuItem bug, this is my fix:
>>>   if (contents_) {
>>>     // contents' ownership will be moved to a containerwidget once
>>>     // it is in the widget tree (contentsLoaded). In any case, if
>>>     // contents_ is destroyed elsewhere, we want to know about it.
>>>     contentsDestroyedConnection_ =
>>>       contents_->destroyed().connect(this,
>>> &WMenuItem::contentsDestroyed);
>>>   }
>>>
>> Yes, this fixes the regression.
>>
>>>
>>>
>>> With this fix, and with the following little modification to your
>>> example program, I think the behaviour is as expected?
>>>  WMenu* const m = new WMenu(new WStackedWidget(root()));
>>>
>> This fixes error in my test case :-)
>> But the test case in the attachment demonstrates another bug -- it's
>>  about incorrect internal path handling by WMenu (when the user uses
>> submenus which participates in the internal path handling). Please,
>> see the attachment.
>>
>>
>>
>> --
>> // Dmitriy.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> witty-interest mailing list
>> witty-interest@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>>
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> witty-interest mailing list
> witty-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>
I've attached a new test case which describes and demonstrates the bug.

-- 
// Dmitriy.
// -*- C++ -*-
// 
// (C) 2013 Dmitry Igrishin
//
// Bug report.
// Description: incorrect WMenu internal path handling for submenu items.
// How to reproduce:
// 1) Open URL: host (or host/search)
//    (works as expected)
// 2) Open URL: host/settings
//    (OOPS, submenu "More" does not handle internal path at all since
//    unnecessary check -- if (!parentItem_) in
//    WMenu::handleInternalPathChange(const std::string&))

#include <Wt/WApplication>
#include <Wt/WMenu>
#include <Wt/WMenuItem>
#include <Wt/WPopupMenu>
#include <Wt/WStackedWidget>
#include <Wt/WText>

using namespace Wt;

namespace {

class App : public WApplication {
public:
  App(const WEnvironment& e);
private:
  WMenu*
  make_menu(WStackedWidget*);

  WPopupMenu*
  make_submenu(WStackedWidget*);
};

App::App(const WEnvironment& e)
  : WApplication(e)
{
  // Contents associated with menu's and submenu's items will
  // be placed in the same WStackedWidget.
  WStackedWidget* const stack = new WStackedWidget(root());
  root()->insertBefore(make_menu(stack), stack);
}

WMenu*
App::make_menu(WStackedWidget* const stack)
{
  WMenu* const m = new WMenu(stack);
  m->setInternalPathEnabled("/");

  // Menuitem "Search" (participates in the internal path).
  WMenuItem* mi = new WMenuItem("Search", new WText("Search page"));
  mi->setInternalPathEnabled(true);
  mi->setPathComponent("search");
  m->addItem(mi);

  // Menuitem "More" (does *not* participates in the internal path,
  // has no associated content. Item just for popup the submenu.
  mi = new WMenuItem("More");
  mi->setInternalPathEnabled(false);
  mi->setMenu(make_submenu(stack));
  m->addItem(mi);

  return m;
}

WPopupMenu*
App::make_submenu(WStackedWidget* const stack)
{
  WPopupMenu* const m = new WPopupMenu(stack);
  m->setInternalPathEnabled("/");

  // Menuitem "Settings" of the submenu "More"
  // (participates in the internal path).
  WMenuItem* const mi = new WMenuItem("Settings", new WText("Settings page"));
  mi->setInternalPathEnabled(true);
  mi->setPathComponent("settings"); // NOTE: this *internal path* will *not*
                                    // be handled (if you specify it in the
                                    // browser's bar manually) by
                                    // WMenu::handleInternalPathChange! -- this
                                    // is a BUG.
  m->addItem(mi);

  return m;
}

WApplication*
create_app(const WEnvironment& env)
{
  return new App(env);
}

} // namespace

int
main(int argc, char* argv[])
{
  return WRun(argc, argv, create_app);
}
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&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