Bug #877
closedWMenu: adding submenu's dynamically adds content to the parent menu
0%
Description
Hi,
I dynamically add an item to a submenu. If I click that new subitem, and then directly click his parent, the data of the subitem is appended to the parent (and also to the parents sibblings). It dissappears only after clicking one of the sibblings of the submenu.
The attached screenshot shows the result on the right after clicking:
-'level 2. option 1'
- the button to add the 'option 2' dynamically
- the added 'level 2, option 2'
- the (parent) 'level 1, option a'
For the left you afterwards click on: - 'level 2, option 1'
- the (parent) 'level 1, option a'
I would expect twice the result on the left, which is the only content that is set for menuitem 'level 1, option a'
void HelloApplication::create()
{
WStackedWidget *contentsStack = new WStackedWidget();
// menu level 1
WMenu *topmenubar = new WMenu(contentsStack, Vertical);
topmenubar->addItem("level 1, option a", new WText("level 1, option a"));
WMenu *menubar = new WMenu(contentsStack, Vertical);
WSubMenuItem *submenubar = new WSubMenuItem("level 1, option b", new WText("level 1, option b"));
// submenu level 2
WPushButton *add_option2_button = new WPushButton();
add_option2_button->clicked().connect(bind(&HelloApplication::add_option, this));
add_option2_button->setText("Add option 2");
WMenuItem *item_1 = new WMenuItem("level 2, option 1", add_option2_button);
menubar*->addItem(item_1*);
submenubar*->setSubMenu(menubar*);
topmenubar*->addItem(submenubar*);
// assign so we can use this in our add_option() method
menu_ = menubar;
WHBoxLayout *layout = new WHBoxLayout();
layout*->addWidget(topmenubar*);
layout*->addWidget(contentsStack*);
root()->setLayout(layout, AlignTop);
// level 2, option 3
WMenuItem *item_3 = new WMenuItem("level 2, option 3", new WText("level 2, option 3"));
menu*->addItem(item_3*_);
}
void HelloApplication::add_option()
{
WMenuItem *item_2 = new WMenuItem("level 2, option 2", new WText("level 2, option 2"));
menu*->addItem(item_2*_);
}
Files
Updated by Rob Van Dyck over 13 years ago
Forgot to mention that I'm using wt-3.1.9
Updated by Koen Deforche over 13 years ago
- Status changed from New to Resolved
- Assignee set to Koen Deforche
Hey Rob,
Good point. It had to do with stateless slot implementations which weren't reset.
The fix is on its way to the git repo.
Regards,
koen
Updated by Rob Van Dyck over 13 years ago
Updated by Koen Deforche over 13 years ago
Hey Rob,
Indeed, the issue was trickier than I thought. I've fixed it now "at a more fundamental level". It's in git.
Regards,
koen
Updated by Koen Deforche over 13 years ago
- Status changed from Resolved to Closed