SelectionListener for MenuItem not called when a MenuListener for Menu is registered [message #461829] |
Sat, 01 October 2005 18:51 |
Eclipse User |
|
|
|
Originally posted by: sarek.nurfuerspam.de
Hi,
we have a problem with a popup menu that has a MenuListener registered
for it and the MenuItems having a SelectionListener for them. We use the
MenuListener to decide whether the items in the menu will be enabled or
not when the menu is shown.
For each menu item we added a selectionListener to handle the event
triggered when the item is selected from the popup menu.
BUT: this does not work in combination ... when the menu listener is
registered for the menu, then the selection listener for the selected
items is not executed when the item is selected. The method
widgetSelected(...) is not called at all.
However, when I comment out the adding of the menuListener, then the
selection listener for the items works.
Here's a small snippet:
> // Create PopUp menu for the lists.
> this.listPopUp = new Menu(this.TabFolder.getShell(), SWT.POP_UP);
> this.listPopUp.addMenuListener(showListener);
>
> this.savePU = new MenuItem(listPopUp, SWT.NONE);
> this.savePU.setText("Save");
> this.savePU.addSelectionListener(popUpListener);
> this.savePU.setEnabled(false);
>
> this.selectAllPU = new MenuItem(listPopUp, SWT.PUSH);
> this.selectAllPU.setText("Select all");
> this.selectAllPU.addSelectionListener(popUpListener);
> this.selectAllPU.setEnabled(false);
>
> this.documentTabList.setMenu(listPopUp);
> this.imageTabList.setMenu(listPopUp);
> this.textTabList.setMenu(listPopUp);
>
in this snippet the selection event for the menuitems is not fired (at
least the widgetSelected method in the listener is not entered) but if I
comment out line 3 (where the menulistener is added), the
selectionEvents for the menu items are fired and handled as I want.
Is this a desired effect? Why can't I combine the two listeners?
Thanks for any help in advance.
Christian
--
To reply to this posting directly you have to remove
the 'NO-SPAM' part from the email address.
|
|
|
Re: SelectionListener for MenuItem not called when a MenuListener for Menu is registered [message #461837 is a reply to message #461829] |
Sun, 02 October 2005 11:24 |
Eclipse User |
|
|
|
Originally posted by: sarek.nurfuerspam.de
Hi,
seems that we found the problem ...
On 01.10.2005 20:51, Christian Riedel wrote:
> [...]
> BUT: this does not work in combination ... when the menu listener is
> registered for the menu, then the selection listener for the selected
> items is not executed when the item is selected. The method
> widgetSelected(...) is not called at all.
>
> However, when I comment out the adding of the menuListener, then the
> selection listener for the items works.
> [...]
menuHidden() seems to be called before widgetSelected(). BUT in the
menuHidden method we disabled the menuitems again (don't ask why ;-))
So, when the menuHidden method was done, the menuItem, which should have
called widgetSelected() was disabled and therefore the code was not
executed. At least we believe this is the reason.
Anywyas - it works now.
Christain
--
To reply to this posting directly you have to remove
the 'NO-SPAM' part from the email address.
|
|
|
Powered by
FUDForum. Page generated in 0.02744 seconds