javafx.scene.input.KeyCodeCombination Java Examples

The following examples show how to use javafx.scene.input.KeyCodeCombination. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogStage.java    From pdfsam with GNU Affero General Public License v3.0 8 votes vote down vote up
@Inject
public LogStage(LogPane logPane, LogListView logView, List<Image> logos, StylesConfig styles) {
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setCenter(logPane);
    containerPane.setBottom(new ClosePane((a) -> eventStudio().broadcast(HideStageRequest.INSTANCE, "LogStage")));
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(k -> {
        if (this.isShowing() && new KeyCodeCombination(KeyCode.ESCAPE).match(k)) {
            eventStudio().broadcast(HideStageRequest.INSTANCE, "LogStage");
        }
    });
    setScene(scene);
    setTitle(DefaultI18nContext.getInstance().i18n("Log register"));
    getIcons().addAll(logos);
    setMaximized(true);
    eventStudio().addAnnotatedListeners(this);
    this.onShowingProperty().addListener((o, oldVal, newVal) -> logView.scrollToBottomIfShowing());
    eventStudio().add(logView, LOGSTAGE_EVENTSTATION);
}
 
Example #2
Source File: TextEditorPane.java    From logbook-kai with MIT License 6 votes vote down vote up
@FXML
void initialize() {
    WebEngine engine = this.webview.getEngine();
    engine.load(PluginServices.getResource("logbook/gui/text_editor_pane.html").toString());
    engine.getLoadWorker().stateProperty().addListener(
            (ob, o, n) -> {
                if (n == Worker.State.SUCCEEDED) {
                    this.setting();
                }
            });

    KeyCombination copy = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN);
    KeyCombination cut = new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN);

    this.webview.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
        if (copy.match(event) || cut.match(event)) {
            String text = String.valueOf(engine.executeScript("getCopyText()"));

            Platform.runLater(() -> {
                ClipboardContent content = new ClipboardContent();
                content.putString(text);
                Clipboard.getSystemClipboard().setContent(content);
            });
        }
    });
}
 
Example #3
Source File: CommandManagerFX.java    From megan-ce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * converts a swing accelerator key to a JavaFX key combination
 *
 * @param acceleratorKey
 * @return key combination
 */
private static KeyCombination translateAccelerator(KeyStroke acceleratorKey) {
    final List<KeyCombination.Modifier> modifiers = new ArrayList<>();

    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.SHIFT_DOWN);
    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.CONTROL_DOWN);
    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.ALT_DOWN);
    if ((acceleratorKey.getModifiers() & InputEvent.META_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.META_DOWN);

    KeyCode keyCode = FXSwingUtilities.getKeyCodeFX(acceleratorKey.getKeyCode());
    return new KeyCodeCombination(keyCode, modifiers.toArray(new KeyCombination.Modifier[0]));
}
 
Example #4
Source File: UITest.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<KeyCode> getKeyCodes(KeyCodeCombination combination) {
    List<KeyCode> keys = new ArrayList<>();
    if (combination.getAlt() == KeyCombination.ModifierValue.DOWN) {
        keys.add(KeyCode.ALT);
    }
    if (combination.getShift() == KeyCombination.ModifierValue.DOWN) {
        keys.add(KeyCode.SHIFT);
    }
    if (combination.getMeta() == KeyCombination.ModifierValue.DOWN) {
        keys.add(KeyCode.META);
    }
    if (combination.getControl() == KeyCombination.ModifierValue.DOWN) {
        keys.add(KeyCode.CONTROL);
    }
    if (combination.getShortcut() == KeyCombination.ModifierValue.DOWN) {
        // Fix bug with internal method not having a proper code for SHORTCUT.
        // Dispatch manually based on platform.
        if (PlatformSpecific.isOnMac()) {
            keys.add(KeyCode.META);
        } else {
            keys.add(KeyCode.CONTROL);
        }
    }
    keys.add(combination.getCode());
    return keys;
}
 
Example #5
Source File: OpenLabeler.java    From OpenLabeler with Apache License 2.0 6 votes vote down vote up
private void initOSMac(ResourceBundle bundle) {
    MenuToolkit tk = MenuToolkit.toolkit();

    String appName = bundle.getString("app.name");
    Menu appMenu = new Menu(appName); // Name for appMenu can't be set at Runtime

    MenuItem aboutItem = tk.createAboutMenuItem(appName, createAboutStage(bundle));

    MenuItem prefsItem = new MenuItem(bundle.getString("menu.preferences"));
    prefsItem.acceleratorProperty().set(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN));
    prefsItem.setOnAction(event -> new PreferencePane().showAndWait());

    appMenu.getItems().addAll(aboutItem, new SeparatorMenuItem(), prefsItem, new SeparatorMenuItem(),
            tk.createHideMenuItem(appName), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(),
            new SeparatorMenuItem(), tk.createQuitMenuItem(appName));

    Menu windowMenu = new Menu(bundle.getString("menu.window"));
    windowMenu.getItems().addAll(tk.createMinimizeMenuItem(), tk.createZoomMenuItem(), tk.createCycleWindowsItem(),
            new SeparatorMenuItem(), tk.createBringAllToFrontItem());

    // Update the existing Application menu
    tk.setForceQuitOnCmdQ(false);
    tk.setApplicationMenu(appMenu);
}
 
Example #6
Source File: SortingVisualization.java    From JavaFX-Tutorial-Codes with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException {
    Parent parent = FXMLLoader.load(SortingVisualization.class.getResource("/sortingvisualization/ui/graphview.fxml"));

    Scene scene = new Scene(parent);
    primaryStage.setTitle("Sorting Visualization");
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.getIcons().add(new Image(SortingVisualization.class.getResourceAsStream("/sortingvisualization/assets/genuine_coder_logo.png")));

    primaryStage.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
        if (event.getCode() == KeyCode.F12) {
            boolean newValue = !primaryStage.isFullScreen();
            primaryStage.setAlwaysOnTop(newValue);
            primaryStage.setFullScreenExitKeyCombination(new KeyCodeCombination(KeyCode.E));
            primaryStage.setFullScreen(newValue);
        }
    });
}
 
Example #7
Source File: PdfsamApp.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
private Scene initScene() {
    MainPane mainPane = injector.instance(MainPane.class);

    NotificationsContainer notifications = injector.instance(NotificationsContainer.class);
    StackPane main = new StackPane();
    StackPane.setAlignment(notifications, Pos.BOTTOM_RIGHT);
    StackPane.setAlignment(mainPane, Pos.TOP_LEFT);
    main.getChildren().addAll(mainPane, notifications);

    StylesConfig styles = injector.instance(StylesConfig.class);

    Scene mainScene = new Scene(main);
    mainScene.getStylesheets().addAll(styles.styles());
    mainScene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN),
            () -> eventStudio().broadcast(ShowStageRequest.INSTANCE, "LogStage"));
    mainScene.getAccelerators().put(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN),
            () -> Platform.exit());
    return mainScene;
}
 
Example #8
Source File: EcoController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example #9
Source File: OtherController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example #10
Source File: AppContextMenu.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
@Inject
AppContextMenu(WorkspaceMenu workspace, ModulesMenu modulesMenu) {
    MenuItem exit = new MenuItem(DefaultI18nContext.getInstance().i18n("E_xit"));
    exit.setOnAction(e -> Platform.exit());
    exit.setAccelerator(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN));
    getItems().addAll(workspace, modulesMenu);
    if (!Boolean.getBoolean(PreferencesDashboardItem.PDFSAM_DISABLE_SETTINGS_DEPRECATED)
            && !Boolean.getBoolean(PreferencesDashboardItem.PDFSAM_DISABLE_SETTINGS)) {
        MenuItem settings = new MenuItem(DefaultI18nContext.getInstance().i18n("_Settings"));
        settings.setOnAction(
                e -> eventStudio().broadcast(new SetActiveDashboardItemRequest(PreferencesDashboardItem.ID)));
        getItems().add(settings);
    }

    getItems().addAll(new SeparatorMenuItem(), exit);
}
 
Example #11
Source File: ConversationController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example #12
Source File: LogFX.java    From LogFX with GNU General Public License v3.0 6 votes vote down vote up
@MustCallOnJavaFXThread
private Menu fileMenu() {
    Menu menu = new Menu( "_File" );
    menu.setMnemonicParsing( true );

    MenuItem open = new MenuItem( "_Open File" );
    open.setAccelerator( new KeyCodeCombination( KeyCode.O, KeyCombination.SHORTCUT_DOWN ) );
    open.setMnemonicParsing( true );
    open.setOnAction( ( event ) -> new FileOpener( stage, this::open ) );

    MenuItem showLogFxLog = new MenuItem( "Open LogFX Log" );
    showLogFxLog.setAccelerator( new KeyCodeCombination( KeyCode.O,
            KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN ) );
    showLogFxLog.setOnAction( ( event ) ->
            open( LogFXLogFactory.INSTANCE.getLogFilePath().toFile() ) );

    MenuItem close = new MenuItem( "E_xit" );
    close.setAccelerator( new KeyCodeCombination( KeyCode.W,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    close.setMnemonicParsing( true );
    close.setOnAction( ( event ) -> stage.close() );
    menu.getItems().addAll( open, showLogFxLog, close );

    return menu;
}
 
Example #13
Source File: SelectionTable.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initTopSectionContextMenu(ContextMenu contextMenu, boolean hasRanges) {
    MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set destination"),
            MaterialDesignIcon.AIRPLANE_LANDING);
    setDestinationItem.setOnAction(e -> eventStudio().broadcast(
            requestDestination(getSelectionModel().getSelectedItem().descriptor().getFile(), getOwnerModule()),
            getOwnerModule()));
    setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));

    selectionChangedConsumer = e -> setDestinationItem.setDisable(!e.isSingleSelection());
    contextMenu.getItems().add(setDestinationItem);

    if (hasRanges) {
        MenuItem setPageRangesItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set as range for all"),
                MaterialDesignIcon.FORMAT_INDENT_INCREASE);
        setPageRangesItem.setOnAction(e -> eventStudio().broadcast(
                new SetPageRangesRequest(getSelectionModel().getSelectedItem().pageSelection.get()),
                getOwnerModule()));
        setPageRangesItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
        selectionChangedConsumer = selectionChangedConsumer
                .andThen(e -> setPageRangesItem.setDisable(!e.isSingleSelection()));
        contextMenu.getItems().add(setPageRangesItem);
    }
    contextMenu.getItems().add(new SeparatorMenuItem());
}
 
Example #14
Source File: GuiMain.java    From BlockMap with MIT License 6 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
	try {
		this.stage = stage;
		stage.setTitle("BlockMap map viewer");
		stage.getIcons().add(new Image(getClass().getResourceAsStream("icon.png")));

		Scene scene = new Scene(root, 700, 450);
		scene.getStylesheets().add("/de/piegames/blockmap/gui/standalone/style.css");
		stage.setScene(scene);
		stage.show();
		scene.getAccelerators().put(new KeyCodeCombination(KeyCode.L, ModifierValue.UP, ModifierValue.DOWN, ModifierValue.UP,
				ModifierValue.UP, ModifierValue.ANY), controller.worldInput::requestFocus);

		GuiMainPreloader.splashScreen.hide();

		/* Put this last to guarantee that the application is fully initialized once instance!=null. */
		instance = this;
	} catch (Throwable t) {
		checkLogger();
		log.fatal("Cannot start BlockMap", t);
		System.exit(-1);
	}
}
 
Example #15
Source File: TextElement.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
@Override
protected void setupMenu(){

	NodeMenuItem item1 = new NodeMenuItem(new HBox(), TR.tr("Supprimer"), false);
	item1.setAccelerator(new KeyCodeCombination(KeyCode.DELETE));
	item1.setToolTip(TR.tr("Supprime cet élément. Il sera donc retiré de l'édition."));
	NodeMenuItem item2 = new NodeMenuItem(new HBox(), TR.tr("Dupliquer"), false);
	item2.setToolTip(TR.tr("Crée un second élément identique à celui-ci."));
	NodeMenuItem item3 = new NodeMenuItem(new HBox(), TR.tr("Ajouter aux éléments précédents"), false);
	item3.setToolTip(TR.tr("Ajoute cet élément à la liste des éléments précédents."));
	NodeMenuItem item4 = new NodeMenuItem(new HBox(), TR.tr("Ajouter aux éléments Favoris"), false);
	item4.setToolTip(TR.tr("Ajoute cet élément à la liste des éléments favoris."));
	menu.getItems().addAll(item1, item2, item4, item3);
	NodeMenuItem.setupMenu(menu);

	item1.setOnAction(e -> delete());
	item2.setOnAction(e -> cloneOnDocument());
	item3.setOnAction(e -> TextTreeView.addSavedElement(this.toNoDisplayTextElement(TextTreeSection.LAST_TYPE, true)));
	item4.setOnAction(e -> TextTreeView.addSavedElement(this.toNoDisplayTextElement(TextTreeSection.FAVORITE_TYPE, true)));
}
 
Example #16
Source File: MainController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example #17
Source File: ConsolePane.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private Menu getCommandsMenu ()
{
  Menu menuCommands = new Menu ("Commands");

  MenuItem menuItemToggleScreens =
      getMenuItem ("Screen history", e -> toggleHistory (), KeyCode.S);

  menuItemAssistant =
      getMenuItem ("Transfers", e -> screen.getAssistantStage ().show (), KeyCode.T);

  menuItemConsoleLog =
      getMenuItem ("Console log", e -> screen.getConsoleLogStage ().show (), KeyCode.L);
  setIsConsole (false);

  menuCommands.getItems ().addAll (menuItemToggleScreens, menuItemAssistant,
                                   menuItemConsoleLog, new SeparatorMenuItem (),
                                   screen.getMenuItemUpload (),
                                   screen.getMenuItemDownload ());

  if (!SYSTEM_MENUBAR)
  {
    MenuItem quitMenuItem = new MenuItem ("Quit");
    menuCommands.getItems ().addAll (new SeparatorMenuItem (), quitMenuItem);
    quitMenuItem.setOnAction (e -> Platform.exit ());
    quitMenuItem.setAccelerator (new KeyCodeCombination (KeyCode.Q,
        KeyCombination.SHORTCUT_DOWN));
  }

  return menuCommands;
}
 
Example #18
Source File: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Install default accelerators
 *
 * @param scene
 */
public void installAccelerators(Scene scene) {
    // Accelerators
    if (stage.isResizable()) {
        scene.getAccelerators().put(new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
            switchFullscreen();
        });
    }
    scene.getAccelerators().put(new KeyCodeCombination(KeyCode.M, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        switchMinimize();
    });
    scene.getAccelerators().put(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> {
        switchClose();
    });
}
 
Example #19
Source File: DatabaseMenu.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create the database menu.
 */
public DatabaseMenu() {
    super(LabelGrabber.INSTANCE.getLabel("database.heading"));

    newSongItem = new MenuItem(LabelGrabber.INSTANCE.getLabel("new.song.button"), new ImageView(new Image(QueleaProperties.get().getUseDarkTheme() ? "file:icons/newsong-light.png" : "file:icons/newsong.png", 16, 16, false, true)));
    newSongItem.setOnAction(new NewSongActionHandler());
    newSongItem.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN));
    getItems().add(newSongItem);

    getItems().add(new SeparatorMenuItem());
    importMenu = new ImportMenu();
    getItems().add(importMenu);
    exportMenu = new ExportMenu();
    getItems().add(exportMenu);
}
 
Example #20
Source File: LabelSourceState.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public KeyAndMouseBindings createKeyAndMouseBindings() {
	final KeyAndMouseBindings bindings = new KeyAndMouseBindings();
	try {
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.SELECT_ALL, new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.SELECT_ALL_IN_CURRENT_VIEW, new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.LOCK_SEGEMENT, new KeyCodeCombination(KeyCode.L)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.NEXT_ID, new KeyCodeCombination(KeyCode.N)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.COMMIT_DIALOG, new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.MERGE_ALL_SELECTED, new KeyCodeCombination(KeyCode.ENTER, KeyCombination.CONTROL_DOWN)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.ENTER_SHAPE_INTERPOLATION_MODE, new KeyCodeCombination(KeyCode.S)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.EXIT_SHAPE_INTERPOLATION_MODE, new KeyCodeCombination(KeyCode.ESCAPE)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.SHAPE_INTERPOLATION_APPLY_MASK, new KeyCodeCombination(KeyCode.ENTER)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.SHAPE_INTERPOLATION_EDIT_SELECTION_1, new KeyCodeCombination(KeyCode.DIGIT1)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.SHAPE_INTERPOLATION_EDIT_SELECTION_2, new KeyCodeCombination(KeyCode.DIGIT2)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.ARGB_STREAM_INCREMENT_SEED, new KeyCodeCombination(KeyCode.C)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.ARGB_STREAM_DECREMENT_SEED, new KeyCodeCombination(KeyCode.C, KeyCombination.SHIFT_DOWN)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.REFRESH_MESHES, new KeyCodeCombination(KeyCode.R)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.CANCEL_3D_FLOODFILL, new KeyCodeCombination(KeyCode.ESCAPE)));
		bindings.getKeyCombinations().addCombination(new NamedKeyCombination(BindingKeys.TOGGLE_NON_SELECTED_LABELS_VISIBILITY, new KeyCodeCombination(KeyCode.V, KeyCombination.SHIFT_DOWN)));

	} catch (NamedKeyCombination.CombinationMap.KeyCombinationAlreadyInserted keyCombinationAlreadyInserted) {
		keyCombinationAlreadyInserted.printStackTrace();
		// TODO probably not necessary to check for exceptions here, but maybe throw runtime exception?
	}
	return bindings;
}
 
Example #21
Source File: Pikatimer.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    
    //stash the primaryStage in the event object
    mainStage=primaryStage;
    
    primaryStage.setTitle("PikaTimer " + VERSION);
    
    mainStage.setWidth(600);
    mainStage.setHeight(400);
    
    
    Pane myPane = (Pane)FXMLLoader.load(getClass().getResource("FXMLopenEvent.fxml"));
    Scene myScene = new Scene(myPane);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();  
  
    //set Stage boundaries so that the main screen is centered.                
    primaryStage.setX((primaryScreenBounds.getWidth() - primaryStage.getWidth())/2);  
    primaryStage.setY((primaryScreenBounds.getHeight() - primaryStage.getHeight())/2);  
 
    // F11 to toggle fullscreen mode
    myScene.getAccelerators().put(new KeyCodeCombination(KeyCode.F11), () -> {
        mainStage.setFullScreen(mainStage.fullScreenProperty().not().get());
    });
    
    // Icons
    String[] sizes = {"256","128","64","48","32"};
    for(String s: sizes){
        primaryStage.getIcons().add(new Image("resources/icons/Pika_"+s+".ico"));
        primaryStage.getIcons().add(new Image("resources/icons/Pika_"+s+".png"));
    }
    
    
    primaryStage.setScene(myScene);
    primaryStage.show();
    
    System.out.println("Exiting Pikatimer.start()");
}
 
Example #22
Source File: KeyHandler.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
public KeyHandler(String comboText) {
    KeyCode testCode = KeyCode.getKeyCode(comboText);
    if (testCode != null) {
        key = testCode;
    } else {
        init(KeyCodeCombination.valueOf(comboText));
    }
}
 
Example #23
Source File: FilterTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void filterTextField_multiplePanels_correctPanelFiltered() {
    ListPanel issuePanel = getPanel(0);

    // filter panel 1
    clickFilterTextFieldAtPanel(0);
    selectAll();
    type("id:4");
    push(KeyCode.ENTER);
    PlatformEx.waitOnFxThread();
    assertEquals(1, issuePanel.getIssuesCount());

    // create new panel 2
    pushKeys(new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN));
    PlatformEx.waitOnFxThread();
    ListPanel issuePanel2 = getPanel(1);

    // filter once
    clickFilterTextFieldAtPanel(1);
    type("id:3");
    push(KeyCode.ENTER);
    PlatformEx.waitOnFxThread();
    assertEquals(1, issuePanel2.getIssuesCount());

    // filter again and check if the correct panel is filtered (and the other panel is untouched)
    clickFilterTextFieldAtPanel(1);
    selectAll();
    push(KeyCode.BACK_SPACE);
    push(KeyCode.ENTER);
    PlatformEx.waitOnFxThread();
    assertEquals(DummyRepoState.NO_OF_DUMMY_ISSUES, issuePanel2.getIssuesCount());
    assertEquals(1, issuePanel.getIssuesCount());

    pushKeys(new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN));
}
 
Example #24
Source File: RootLayoutController.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
private void setShortcutKeys() {
    archiveMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN));
    findMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN));
    preferencesMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN));
    if (OSHelper.isMacOS()) {
        deleteMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.SHORTCUT_DOWN));
    } else {
        deleteMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.DELETE, KeyCombination.SHORTCUT_DOWN));
    }
    cancelMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.ESCAPE));
    expandMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.CLOSE_BRACKET, KeyCombination.SHORTCUT_DOWN));
    collapseMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.OPEN_BRACKET, KeyCombination.SHORTCUT_DOWN));
}
 
Example #25
Source File: KeyboardShortcuts.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Map<Integer, KeyCodeCombination> populateJumpToNthIssueMap() {
    Map<Integer, KeyCodeCombination> result = new HashMap<>();
    result.put(1, new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN));
    result.put(2, new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN));
    result.put(3, new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.SHORTCUT_DOWN));
    result.put(4, new KeyCodeCombination(KeyCode.DIGIT4, KeyCombination.SHORTCUT_DOWN));
    result.put(5, new KeyCodeCombination(KeyCode.DIGIT5, KeyCombination.SHORTCUT_DOWN));
    result.put(6, new KeyCodeCombination(KeyCode.DIGIT6, KeyCombination.SHORTCUT_DOWN));
    result.put(7, new KeyCodeCombination(KeyCode.DIGIT7, KeyCombination.SHORTCUT_DOWN));
    result.put(8, new KeyCodeCombination(KeyCode.DIGIT8, KeyCombination.SHORTCUT_DOWN));
    result.put(9, new KeyCodeCombination(KeyCode.DIGIT9, KeyCombination.SHORTCUT_DOWN));
    return Collections.unmodifiableMap(result);
}
 
Example #26
Source File: LogFX.java    From LogFX with GNU General Public License v3.0 5 votes vote down vote up
@MustCallOnJavaFXThread
private Menu viewMenu() {
    Menu menu = new Menu( "_View" );
    menu.setMnemonicParsing( true );

    CheckMenuItem highlight = new CheckMenuItem( "_Highlight Options" );
    highlight.setAccelerator( new KeyCodeCombination( KeyCode.H, KeyCombination.SHORTCUT_DOWN ) );
    highlight.setMnemonicParsing( true );
    bindMenuItemToDialog( highlight, () ->
            showHighlightOptionsDialog( highlightOptions ) );

    MenuItem orientation = new MenuItem( "Switch Pane Orientation" );
    orientation.setAccelerator( new KeyCodeCombination( KeyCode.S,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    orientation.setOnAction( event -> logsPane.switchOrientation() );

    CheckMenuItem font = new CheckMenuItem( "Fon_t" );
    font.setAccelerator( new KeyCodeCombination( KeyCode.F,
            KeyCombination.SHIFT_DOWN, KeyCombination.SHORTCUT_DOWN ) );
    font.setMnemonicParsing( true );
    bindMenuItemToDialog( font, () -> showFontPicker( config.fontProperty() ) );

    CheckMenuItem filter = new CheckMenuItem( "Enable _filters" );
    filter.setAccelerator( new KeyCodeCombination( KeyCode.F,
            KeyCombination.SHORTCUT_DOWN ) );
    filter.setMnemonicParsing( true );
    filter.selectedProperty().bindBidirectional( config.filtersEnabledProperty() );

    MenuItem showContextMenu = new MenuItem( "Show Context Menu" );
    showContextMenu.setAccelerator( new KeyCodeCombination( KeyCode.E, KeyCombination.SHORTCUT_DOWN ) );
    showContextMenu.setOnAction( event -> logsPane.showContextMenu() );

    menu.getItems().addAll( highlight, orientation, font, filter, showContextMenu );
    return menu;
}
 
Example #27
Source File: ConsolePane.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private MenuItem getMenuItem (String text, EventHandler<ActionEvent> eventHandler,
    KeyCode keyCode)
{
  MenuItem menuItem = new MenuItem (text);
  menuItem.setOnAction (eventHandler);
  menuItem
      .setAccelerator (new KeyCodeCombination (keyCode, KeyCombination.SHORTCUT_DOWN));
  return menuItem;
}
 
Example #28
Source File: TransferMenu.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private MenuItem getMenuItem (String text, EventHandler<ActionEvent> eventHandler,
    KeyCode keyCode)
{
  MenuItem menuItem = new MenuItem (text);
  menuItem.setOnAction (eventHandler);
  menuItem
      .setAccelerator (new KeyCodeCombination (keyCode, KeyCombination.SHORTCUT_DOWN));
  return menuItem;
}
 
Example #29
Source File: BetonQuestEditor.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
private void createPrimaryStage() throws IOException {
	URL location = getClass().getResource("view/Root.fxml");
	Locale locale = Persistence.getSettings().getLanguage();
	language = ResourceBundle.getBundle("pl.betoncraft.betonquest.editor.resource.lang.lang", locale);
	FXMLLoader fxmlLoader = new FXMLLoader(location, language);
	BorderPane root = (BorderPane) fxmlLoader.load();
	TabsController.setDisabled(true);
	Scene scene = new Scene(root, 1280, 720);
	scene.getStylesheets().add(getClass().getResource("resource/style.css").toExternalForm());
	KeyCombination save = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN);
	KeyCombination export = new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN);
	scene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
		if (save.match(event)) {
			event.consume();
			MainMenuController.getInstance().save();
		} else if (export.match(event)) {
			event.consume();
			MainMenuController.getInstance().export();
		}
	});
	stage.setScene(scene);
	stage.setTitle(language.getString("betonquest-editor"));
	stage.getIcons().add(new Image(getClass().getResourceAsStream("resource/icon.png")));
	stage.setMinHeight(600);
	stage.setMinWidth(800);
	stage.setMaximized(true);
	stage.show();
}
 
Example #30
Source File: TranslationController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML public void translationKey(KeyEvent event) {
	try {
		KeyCombination enter = new KeyCodeCombination(KeyCode.ENTER, KeyCombination.CONTROL_DOWN);
		KeyCombination backspace = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.CONTROL_DOWN);
		if (enter.match(event)) {
			next();
		} else if (backspace.match(event)) {
			previous();
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}