public void keyTyped(java.awt.event.KeyEvent e) { if (e.getKeyChar() != java.awt.event.KeyEvent.CHAR_UNDEFINED && !e.isActionKey() && (e.getModifiers() & getToolkit().getMenuShortcutKeyMask()) == 0) { org.nlogo.window.ButtonWidget button = findActionButton(e.getKeyChar()); if (button != null) { button.keyTriggered(); } } }
private void enableButtonKeys(boolean enabled) { java.awt.Component[] comps = getComponents(); for (int i = 0; i < comps.length; i++) { if (comps[i] instanceof WidgetWrapper) { Widget widget = ((WidgetWrapper) comps[i]).widget(); if (widget instanceof org.nlogo.window.ButtonWidget) { org.nlogo.window.ButtonWidget button = (org.nlogo.window.ButtonWidget) widget; button.keyEnabled(enabled); } } } }
private org.nlogo.window.ButtonWidget findActionButton(char key) { java.awt.Component[] comps = getComponents(); for (int i = 0; i < comps.length; i++) { if (comps[i] instanceof WidgetWrapper) { Widget widget = ((WidgetWrapper) comps[i]).widget(); if (widget instanceof org.nlogo.window.ButtonWidget) { org.nlogo.window.ButtonWidget button = (org.nlogo.window.ButtonWidget) widget; if (Character.toUpperCase(button.actionKey()) == Character.toUpperCase(key)) { return button; } } } } return null; }
@Override public boolean isFocusable() { java.awt.Component[] comps = getComponents(); for (int i = 0; i < comps.length; i++) { if (comps[i] instanceof WidgetWrapper) { Widget widget = ((WidgetWrapper) comps[i]).widget(); if (widget instanceof org.nlogo.window.ButtonWidget) { org.nlogo.window.ButtonWidget button = (org.nlogo.window.ButtonWidget) widget; if (button.actionKey() != '\0' && button.actionKey() != ' ') { return true; } } } } return false; }