Project

General

Profile

Actions

Bug #877

closed

WMenu: adding submenu's dynamically adds content to the parent menu

Added by Rob Van Dyck almost 13 years ago. Updated almost 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
06/28/2011
Due date:
% Done:

0%

Estimated time:

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

WMenu_bug.png (50.2 KB) WMenu_bug.png Rob Van Dyck, 06/28/2011 10:15 AM
Actions #1

Updated by Rob Van Dyck almost 13 years ago

Forgot to mention that I'm using wt-3.1.9

Actions #2

Updated by Koen Deforche almost 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

Actions #3

Updated by Rob Van Dyck almost 13 years ago

Koen, in case this one is fixed in the git repo: I still get the bug [see my comment on #886], in case you haven't committed your fix: ignore this comment and the comment to #886 :-).

Actions #4

Updated by Koen Deforche almost 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

Actions #5

Updated by Koen Deforche almost 13 years ago

  • Target version set to 3.1.10
Actions #6

Updated by Koen Deforche almost 13 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF