类javafx.scene.input.KeyCombination源码实例Demo

下面列出了怎么用javafx.scene.input.KeyCombination的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: OpenLabeler   文件: OpenLabeler.java
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);
}
 
源代码2 项目: Path-of-Leveling   文件: POELevelFx.java
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;
}
 
源代码3 项目: Project-16x16   文件: SideScroller.java
/**
 * 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;
}
 
源代码4 项目: marathonv5   文件: FXContextMenuTriggers.java
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();
}
 
源代码5 项目: megan-ce   文件: CommandManagerFX.java
/**
 * 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]));
}
 
源代码6 项目: triplea   文件: TripleA.java
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();
      });
}
 
源代码7 项目: JetUML   文件: TestMenuFactory.java
@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());
	}
}
 
源代码8 项目: BetonQuest-Editor   文件: EcoController.java
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;
	}
}
 
源代码9 项目: BetonQuest-Editor   文件: OtherController.java
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;
	}
}
 
源代码10 项目: BetonQuest-Editor   文件: ConversationController.java
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;
	}
}
 
源代码11 项目: BetonQuest-Editor   文件: MainController.java
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;
	}
}
 
源代码12 项目: LogFX   文件: LogFX.java
@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;
}
 
源代码13 项目: logbook-kai   文件: TextEditorPane.java
@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);
            });
        }
    });
}
 
源代码14 项目: HubTurbo   文件: UITest.java
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;
}
 
源代码15 项目: erlyberly   文件: TermTreeView.java
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));
}
 
源代码16 项目: pdfsam   文件: PdfsamApp.java
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;
}
 
源代码17 项目: pdfsam   文件: AppContextMenu.java
@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);
}
 
源代码18 项目: pdfsam   文件: SelectionTable.java
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());
}
 
源代码19 项目: sis   文件: Main.java
/**
 * 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();
}
 
源代码20 项目: milkman   文件: PlatformUtil.java
public static KeyCombination getControlKeyCombination(KeyCode keyCode){
	KeyCombination.Modifier controlKey = KeyCombination.CONTROL_DOWN;
	if (SystemUtils.IS_OS_MAC){
		controlKey = KeyCombination.META_DOWN;
	}
	return new KeyCodeCombination(keyCode, controlKey);
}
 
源代码21 项目: PDF4Teachers   文件: NodeMenuItem.java
public void setKeyCombinaison(KeyCombination keyCombinaison){

        Label acceleratorLabel = new Label(keyCombinaison.getDisplayText());
        if(fat) acceleratorLabel.setStyle("-fx-font-size: 13; -fx-padding: 9 10 9 10;"); // top - right - bottom - left
        else acceleratorLabel.setStyle("-fx-font-size: 13; -fx-padding: 5 10 5 10;");  // top - right - bottom - left
        getNode().getChildren().set(4, acceleratorLabel);

        setAccelerator(keyCombinaison);
    }
 
源代码22 项目: pdfsam   文件: SelectionTable.java
private void initBottomSectionContextMenu(ContextMenu contextMenu) {

        MenuItem copyItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Copy to clipboard"),
                MaterialDesignIcon.CONTENT_COPY);
        copyItem.setOnAction(e -> copySelectedToClipboard());

        MenuItem infoItem = createMenuItem(DefaultI18nContext.getInstance().i18n("Document properties"),
                MaterialDesignIcon.INFORMATION_OUTLINE);
        infoItem.setOnAction(e -> Platform.runLater(() -> eventStudio()
                .broadcast(new ShowPdfDescriptorRequest(getSelectionModel().getSelectedItem().descriptor()))));

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

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

        copyItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN));
        infoItem.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.ALT_DOWN));
        openFileItem.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));
        openFolderItem.setAccelerator(
                new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN, KeyCombination.ALT_DOWN));

        contextMenu.getItems().addAll(new SeparatorMenuItem(), copyItem, infoItem, openFileItem, openFolderItem);

        selectionChangedConsumer = selectionChangedConsumer.andThen(e -> {
            copyItem.setDisable(e.isClearSelection());
            infoItem.setDisable(!e.isSingleSelection());
            openFileItem.setDisable(!e.isSingleSelection());
            openFolderItem.setDisable(!e.isSingleSelection());
        });
    }
 
源代码23 项目: Path-of-Leveling   文件: Preferences_Controller.java
private KeyCombination saveKeybinds(Properties prop, String propertyName, String kc_field_text){
    prop.setProperty(propertyName, kc_field_text);
    KeyCombination keyCombination = null;
    try{
        keyCombination = KeyCombination.keyCombination(kc_field_text);
        System.out.println("-Preferences- Saved keybind : " + keyCombination.getName()+ " for "+propertyName);
    }catch(Exception e){
        System.out.println("-Preferences- Saving keybind : for "+propertyName + " failed.");
        keyCombination = KeyCombination.NO_MATCH;
    }
    return keyCombination;
}
 
源代码24 项目: Path-of-Leveling   文件: POELevelFx.java
private KeyCombination setKeybinds(Properties prop, String propertyName, String defaultValue){
    prop.setProperty(propertyName, defaultValue);
    KeyCombination keyCombination = null;
    try{
        keyCombination = KeyCombination.keyCombination(defaultValue);
        System.out.println("-POELevelFx- Setting keybind for : " + keyCombination.getName() +" for " + propertyName);
    }catch(Exception e){
        System.out.println("-POELevelFx- Setting keybind for :" + propertyName + " failed.");
        keyCombination = KeyCombination.NO_MATCH;
    }
    return keyCombination;
}
 
源代码25 项目: PreferencesFX   文件: PreferencesFxDialog.java
private void setupDebugHistoryTable() {
  final KeyCombination keyCombination =
      new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN);
  preferencesFxView.getScene().addEventHandler(KeyEvent.KEY_RELEASED, event -> {
    if (keyCombination.match(event)) {
      LOGGER.trace("Opened History Debug View");
      new HistoryDialog(model.getHistory());
    }
  });
}
 
源代码26 项目: OEE-Designer   文件: EventResolverController.java
public void initialize(DesignerApplication app, EventResolver resolver) throws Exception {
	// script engine
	scriptEngine = new ScriptEngineManager().getEngineByName(EquipmentEventResolver.SCRIPT_ENGINE_NAME);

	// main app
	setApp(app);

	// button images
	setImages();

	// script resolver
	setResolver(resolver);

	// insert 4 spaces instead of a 8 char tab
	taScript.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
		final KeyCombination combo = new KeyCodeCombination(KeyCode.TAB);

		@Override
		public void handle(KeyEvent event) {
			// check for only tab key
			if (combo.match(event)) {
				taScript.insertText(taScript.getCaretPosition(), "    ");
				event.consume();
			}
		}
	});
}
 
源代码27 项目: Quelea   文件: DatabaseMenu.java
/**
 * 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);
}
 
源代码28 项目: DevToolBox   文件: Undecorator.java
/**
 * 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();
    });
}
 
源代码29 项目: paintera   文件: LabelSourceState.java
@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;
}
 
源代码30 项目: marathonv5   文件: FXContextMenuTriggers.java
private static void setMenuModifiersFromText(String menuModifiersTxt) {
    String button = menuModifiersTxt.substring(menuModifiersTxt.lastIndexOf('+') + 1);
    if (menuModifiersTxt.contains("+")) {
        String modifiers = menuModifiersTxt.substring(0, menuModifiersTxt.lastIndexOf('+'));
        KeyCombination kc = KeyCombination.valueOf(modifiers + "+A");
        menuModifiers = getDownModifierMask(kc);
        if (button.equals("Button1")) {
            menuModifiers += "Button1";
        } else if (button.equals("Button2")) {
            menuModifiers += "Button2";
        } else if (button.equals("Button3")) {
            menuModifiers += "Button3";
        } else {
            throw new RuntimeException("Unknow button " + button + " in setting mouse trigger");
        }
        return;
    }
    if (button.equals("Button1")) {
        menuModifiers = "Button1";
    } else if (button.equals("Button2")) {
        menuModifiers = "Button2";
    } else if (button.equals("Button3")) {
        menuModifiers = "Button3";
    } else {
        throw new RuntimeException("Unknow button " + button + " in setting mouse trigger");
    }
}
 
 类所在包
 同包方法