Search in sources :

Example 1 with MenuPopup

use of org.apache.pivot.wtk.MenuPopup in project pivot by apache.

the class TerraMenuPopupSkin method install.

@Override
public void install(Component component) {
    super.install(component);
    MenuPopup menuPopup = (MenuPopup) component;
    menuPopup.getMenuPopupListeners().add(this);
    menuPopup.getMenuPopupStateListeners().add(this);
    Menu menu = menuPopup.getMenu();
    if (menu != null) {
        menu.getMenuItemSelectionListeners().add(menuItemSelectionListener);
    }
    panorama.setView(menu);
    menuPopup.setContent(border);
    // Attach the drop-shadow decorator
    if (!themeIsFlat()) {
        dropShadowDecorator = new DropShadowDecorator();
        menuPopup.getDecorators().add(dropShadowDecorator);
    }
}
Also used : MenuPopup(org.apache.pivot.wtk.MenuPopup) Menu(org.apache.pivot.wtk.Menu) DropShadowDecorator(org.apache.pivot.wtk.effects.DropShadowDecorator)

Example 2 with MenuPopup

use of org.apache.pivot.wtk.MenuPopup in project pivot by apache.

the class TerraMenuPopupSkin method windowOpened.

@Override
public void windowOpened(Window window) {
    super.windowOpened(window);
    Display display = window.getDisplay();
    display.getContainerMouseListeners().add(displayMouseListener);
    MenuPopup menuPopup = (MenuPopup) window;
    Menu menu = menuPopup.getMenu();
    if (menu != null) {
        Menu.Item activeItem = menu.getActiveItem();
        if (activeItem != null) {
            activeItem.setActive(false);
        }
        menu.requestFocus();
    }
    panorama.setScrollTop(0);
    // Always ensure that the menu popup fits on the display.
    ApplicationContext.queueCallback(repositionCallback);
}
Also used : MenuPopup(org.apache.pivot.wtk.MenuPopup) Menu(org.apache.pivot.wtk.Menu) Display(org.apache.pivot.wtk.Display)

Example 3 with MenuPopup

use of org.apache.pivot.wtk.MenuPopup in project pivot by apache.

the class TerraMenuPopupSkin method keyPressed.

/**
 * {@link KeyCode#ESCAPE ESCAPE} Close the menu popup.
 */
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
    boolean consumed = super.keyPressed(component, keyCode, keyLocation);
    if (keyCode == Keyboard.KeyCode.ESCAPE) {
        MenuPopup menuPopup = (MenuPopup) getComponent();
        menuPopup.close();
    }
    return consumed;
}
Also used : MenuPopup(org.apache.pivot.wtk.MenuPopup)

Aggregations

MenuPopup (org.apache.pivot.wtk.MenuPopup)3 Menu (org.apache.pivot.wtk.Menu)2 Display (org.apache.pivot.wtk.Display)1 DropShadowDecorator (org.apache.pivot.wtk.effects.DropShadowDecorator)1