/** * Registers a new shortcut listener for the component. * * @param shortcut * the new Listener to be registered. * @return this (for method chaining) * @see AbstractComponent#addShortcutListener(com.vaadin.event.ShortcutListener) */ public default S withShortcutListener(ShortcutListener shortcut) { ((AbstractComponent) this).addShortcutListener(shortcut); return (S) this; }
@Override public B withShortcutListener(ShortcutListener shortcut) { getInstance().addShortcutListener(shortcut); return builder(); }
@Override public B withShortcutListener(ShortcutListener shortcut) { getInstance().addShortcutListener(shortcut); return builder(); }
protected void assignShortcut(Window webWindow, SideMenu.MenuItem menuItem, MenuItem item) { KeyCombination itemShortcut = item.getShortcut(); if (itemShortcut != null) { ShortcutListener shortcut = new SideMenuShortcutListener(menuItem, item); AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class); windowImpl.addShortcutListener(shortcut); if (Strings.isNullOrEmpty(menuItem.getBadgeText())) { menuItem.setDescription(itemShortcut.format()); } } }
protected void assignShortcut(Window webWindow, AppMenu.MenuItem menuItem, MenuItem item) { KeyCombination itemShortcut = item.getShortcut(); if (itemShortcut != null) { ShortcutListener shortcut = new MenuShortcutAction(menuItem, "shortcut_" + item.getId(), item.getShortcut()); AbstractComponent windowImpl = webWindow.unwrap(AbstractComponent.class); windowImpl.addShortcutListener(shortcut); appMenu.setMenuItemShortcutCaption(menuItem, itemShortcut.format()); } }
@Override protected ShortcutListener attachShortcut(String actionId, KeyCombination keyCombination) { ShortcutListener shortcut = new ShortcutListenerDelegate(actionId, keyCombination.getKey().getCode(), KeyCombination.Modifier.codes(keyCombination.getModifiers()) ).withHandler((sender, target) -> { if (target == component) { Action action = getAction(actionId); if (action != null && action.isEnabled() && action.isVisible()) { action.actionPerform(WebAbstractActionsHolderComponent.this); } } }); component.addShortcutListener(shortcut); return shortcut; }