-
23 Apr 2008 6:02 AM #1
Event problem with TextToolItem
Event problem with TextToolItem
Hi ,
A click (Events.Click) on TextToolItem never invoke handleEvent of Listener. "Toggle Click" (Events.Toggle) works fine.
What's wrong? Any idee?
Thanks!
Code:Listener listener = new Listener<BaseEvent>() { public void handleEvent(BaseEvent baseEvent) { Window.alert(((ButtonEvent) baseEvent).button.getText()); } }; final TextToolItem itemExport = new TextToolItem("Export"); itemExport.setToolTip("Show Export Explorer"); itemExport.setIconStyle("icon-export"); itemExport.addListener(Events.Click, listener); final ToggleToolItem itemSynchronise = new ToggleToolItem("Synchroise"); itemSynchronise.setToolTip("Toggle Synchronise Explorer"); itemSynchronise.setIconStyle("icon-synchronise"); itemSynchronise.addListener(Events.Toggle, listener); final ToolBar toolBar = new ToolBar(); toolBar.add(itemExport); toolBar.add(new SeparatorToolItem()); toolBar.add(itemSynchronise);
-
23 Apr 2008 9:45 AM #2
TextToolItem does not fire the Click event, it fires the Select event. Each component should define what events is fires in its javadocs. There is one issue that is being corrected for the next in beta2. TextToolItem wraps a Button and it is the Button that is passed to the listeners in the ButtonEvent.
So you can do this:
You can also use a SelectionListener:Code:TextToolItem standard = new TextToolItem("Click Me"); standard.addListener(Events.Select, new Listener<ButtonEvent>() { public void handleEvent(ButtonEvent be) { System.out.println("bang bang"); } });
Code:standard.addSelectionListener(new SelectionListener() { public void componentSelected(ComponentEvent ce) { System.out.println("i have been selected"); } });


Reply With Quote