pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: How to create menu for MenuButton dynamically
Date Fri, 24 Jun 2011 09:48:59 GMT
It doesn't look like there is any direct support for receiving a
notification once the button has been clicked, but before the menu has been
opened.   Adding a ButtonPressListener to the MenuButton wouldn't really be
any better than listening for the windowOpened event.

(ListButton behaves in the same way)

If you *did* need notification after the click, but before the window
opened, I think it would require a custom skin to override
org.apache.pivot.wtk.skin.MenuButtonSkin.mouseDown(Component, Button, int,
org.apache.pivot.wtk.skin.MenuButtonSkin.keyPressed(Component, int,

Perhaps org.apache.pivot.wtk.MenuHandler needs a new configureMenuButton()
method equivalent to configureContextMenu()?
A MenuHandler property could then be added to MenuButton.


On 24 June 2011 16:27, Edvin Syse <edvin@sysedata.no> wrote:

> Den 24.06.2011 11:17, skrev Edvin Syse:
>  I have a MenuButton where I want to create the menu dynamically before
>> each time it is shown. Where should I attach a listener, and how should I
>> populate the menu each time?
> This seems to work, but is it the correct approach?
> menuButton.getListPopup().getWindowStateListeners().add(new
> WindowStateListener.Adapter() {
>    public void windowOpened(Window window) {
>        Menu menu = new Menu();
>        // Add sections and items
>        menuButton.setMenu(menu);
>        super.windowOpened(window);
>    }
> });
> -- Edvin

View raw message