javafx.scene.input.KeyCombination Java Examples

The following examples show how to use javafx.scene.input.KeyCombination. 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: 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 #2
Source File: SideScroller.java    From Project-16x16 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called by Processing after settings().
 */
@Override
protected PSurface initSurface() {
	surface = (PSurfaceFX) super.initSurface();
	canvas = (Canvas) surface.getNative();
	canvas.widthProperty().unbind(); // used for scaling
	canvas.heightProperty().unbind(); // used for scaling
	scene = canvas.getScene();
	stage = (Stage) scene.getWindow();
	stage.setTitle("Project-16x16");
	stage.setResizable(false); // prevent abitrary user resize
	stage.setFullScreenExitHint(""); // disable fullscreen toggle hint
	stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); // prevent ESC toggling fullscreen
	scene.getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, this::closeWindowEvent);
	return surface;
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
Source File: FXContextMenuTriggers.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private static String getDownModifierMask(KeyCombination kc) {
    StringBuilder contextMenuKeyModifiers = new StringBuilder();
    if (kc.getControl() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Ctrl+");
    }
    if (kc.getAlt() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Alt+");
    }
    if (kc.getMeta() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Meta+");
    }
    if (kc.getShift() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Shift+");
    }
    return contextMenuKeyModifiers.toString();
}
 
Example #8
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 #9
Source File: TestMenuFactory.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testCreateMenuItemWithAll()
{
	MenuItem item = aMenuFactory.createMenuItem("file.open", false, e -> {});
	assertEquals("_Open", item.getText());
	assertNotNull(item.getGraphic());
	KeyCombination accelerator = item.getAccelerator();
	assertNotNull(accelerator);
	if( System.getProperty("os.name", "unknown").toLowerCase().startsWith("mac") )
	{
		assertEquals("Meta+O", accelerator.getName());
	}
	else
	{
		assertEquals(ModifierValue.DOWN, accelerator.getControl());
		assertEquals("Ctrl+O", accelerator.getName());
	}
}
 
Example #10
Source File: POELevelFx.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
private KeyCombination loadKeybinds(Properties prop, String propertyName, String defaultValue){
    //check if hotkey is null, on older versions
    String loadProp = prop.getProperty(propertyName);
    KeyCombination keyCombination = null;
    //this should load the keybind on the controller but not overwrite
    if(loadProp == null){
        //loadProp = defaultValue; <- load default or
        return KeyCombination.NO_MATCH;
    }
    try{
        keyCombination = KeyCombination.keyCombination(loadProp);
        System.out.println("-POELevelFx- Loading keybind " + keyCombination.getName() +" for " + propertyName);
    }catch(Exception e){
        System.out.println("-POELevelFx- Loading keybind for " + propertyName+ " failed.");
        keyCombination = KeyCombination.NO_MATCH;
    }
    return keyCombination;
}
 
Example #11
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 #12
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 #13
Source File: TripleA.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private void setupStage(
    final Stage stage, final Scene scene, final RootActionPane rootActionPane) {
  stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
  // Should be a configurable setting in the future, but for developing it's
  // better to work in non-fullscreen mode
  stage.setFullScreen(false);

  Font.loadFont(TripleA.class.getResourceAsStream(FONT_PATH), 14);
  stage.setScene(scene);
  stage.getIcons().add(new Image(getClass().getResourceAsStream(ICON_LOCATION)));
  stage.setTitle("TripleA");
  stage.show();
  stage.setOnCloseRequest(
      e -> {
        e.consume();
        rootActionPane.promptExit();
      });
}
 
Example #14
Source File: TermTreeView.java    From erlyberly with GNU General Public License v3.0 6 votes vote down vote up
public TermTreeView() {
    getStyleClass().add("term-tree");
    setRoot(new TreeItem<TermTreeItem>());

    MenuItem copyMenuItem = new MenuItem("Copy");
    copyMenuItem.setAccelerator(KeyCombination.keyCombination("shortcut+c"));
    copyMenuItem.setOnAction(this::onCopyCalls);

    MenuItem dictMenuItem = new MenuItem("Dict to List");
    dictMenuItem.setOnAction(this::onViewDict);

    MenuItem hexViewMenuItem = new MenuItem("Hex View");
    hexViewMenuItem.setOnAction(this::onHexView);

    MenuItem decompileFunContextMenu = new MenuItem("Decompile Fun");
    decompileFunContextMenu.setOnAction(this::onDecompileFun);

    setContextMenu(new ContextMenu(copyMenuItem, dictMenuItem, decompileFunContextMenu, hexViewMenuItem));
}
 
Example #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: JFXMenuItem.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setKeyCombination(UIKeyCombination keyCombination) {
	if( this.keyCombination == null || !this.keyCombination.equals(keyCombination)) {
		this.keyCombination = keyCombination;
		
		KeyCombination jfxKeyConvination = null;
		if( this.keyCombination != null ) {
			try {
				StringBuilder sb = new StringBuilder();
				for(UIKey uiKey : this.keyCombination.getKeys()) {
					if( sb.length() > 0 ) {
						sb.append("+");
					}
					if( UIKey.ALT.equals(uiKey) ) {
						sb.append(KeyCode.ALT.getName());
					} else if( UIKey.SHIFT.equals(uiKey) ) {
						sb.append(KeyCode.SHIFT.getName());
					} else if( UIKey.CONTROL.equals(uiKey) ) {
						sb.append(KeyCode.CONTROL.getName());
					} else if( UIKey.COMMAND.equals(uiKey) ) {
						sb.append(KeyCode.META.getName());
					} else {
						sb.append(uiKey.toString());
					}
				}
				jfxKeyConvination = KeyCombination.keyCombination(sb.toString());
			}catch (RuntimeException e) {
				e.printStackTrace();
			}
		}
		this.getControl().setAccelerator(jfxKeyConvination);
	}
}
 
Example #21
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 #22
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 #23
Source File: EmulatorUILogic.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
@InvokableAction(
        name = "Toggle fullscreen",
        category = "general",
        description = "Activate/deactivate fullscreen mode",
        alternatives = "fullscreen;maximize",
        defaultKeyMapping = "ctrl+shift+f")
public static void toggleFullscreen() {
    Platform.runLater(() -> {
        Stage stage = JaceApplication.getApplication().primaryStage;
        stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
        stage.setFullScreen(!stage.isFullScreen());
        JaceApplication.getApplication().controller.setAspectRatioEnabled(stage.isFullScreen());
    });
}
 
Example #24
Source File: SingleSelectionPane.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initContextMenu() {
    MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
            MaterialDesignIcon.INFORMATION_OUTLINE);
    infoItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN));
    infoItem.setOnAction(
            e -> Platform.runLater(() -> eventStudio().broadcast(new ShowPdfDescriptorRequest(descriptor))));

    removeSelected = createMenuItem(DefaultI18nContext.getInstance().i18n("Remove"), MaterialDesignIcon.MINUS);
    removeSelected.setOnAction(e -> eventStudio().broadcast(new ClearModuleEvent(), getOwnerModule()));

    MenuItem setDestinationItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Set destination"),
            MaterialDesignIcon.AIRPLANE_LANDING);
    setDestinationItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.ALT_DOWN));
    setDestinationItem.setOnAction(e -> eventStudio()
            .broadcast(requestDestination(descriptor.getFile(), getOwnerModule()), getOwnerModule()));

    MenuItem openFileItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open"),
            MaterialDesignIcon.FILE_PDF_BOX);
    openFileItem.setOnAction(e -> eventStudio().broadcast(new OpenFileRequest(descriptor.getFile())));

    MenuItem openFolderItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Open Folder"),
            MaterialDesignIcon.FOLDER_OUTLINE);
    openFolderItem
            .setOnAction(e -> eventStudio().broadcast(new OpenFileRequest(descriptor.getFile().getParentFile())));

    field.getTextField().setContextMenu(new ContextMenu(setDestinationItem, new SeparatorMenuItem(), removeSelected,
            new SeparatorMenuItem(), infoItem, openFileItem, openFolderItem));
}
 
Example #25
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 #26
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 #27
Source File: TransferMenu.java    From xframium-java with GNU General Public License v3.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: Main.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked by JavaFX for starting the application.
 * This method is called on the JavaFX Application Thread.
 *
 * @param window  the primary stage onto which the application scene will be be set.
 */
@Override
public void start(final Stage window) {
    this.window = window;
    final Vocabulary vocabulary = Vocabulary.getResources((Locale) null);
    /*
     * Configure the menu bar. For most menu item, the action is to invoke a method
     * of the same name in this application class (e.g. open()).
     */
    final MenuBar menus = new MenuBar();
    final Menu file = new Menu(vocabulary.getString(Vocabulary.Keys.File));
    {
        final MenuItem open = new MenuItem(vocabulary.getMenuLabel(Vocabulary.Keys.Open));
        open.setAccelerator(KeyCombination.keyCombination("Shortcut+O"));
        open.setOnAction(e -> open());

        final MenuItem exit = new MenuItem(vocabulary.getString(Vocabulary.Keys.Exit));
        exit.setOnAction(e -> Platform.exit());
        file.getItems().addAll(open, new SeparatorMenuItem(), exit);
    }
    menus.getMenus().add(file);
    /*
     * Set the main content and show.
     */
    content = new ResourceView();
    final BorderPane pane = new BorderPane();
    pane.setTop(menus);
    pane.setCenter(content.pane);
    Scene scene = new Scene(pane);
    window.setTitle("Apache Spatial Information System");
    window.setScene(scene);
    window.setWidth(800);
    window.setHeight(650);
    window.show();
}
 
Example #29
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 #30
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;
}