javafx.scene.input.KeyCombination.ModifierValue Java Examples

The following examples show how to use javafx.scene.input.KeyCombination.ModifierValue. 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: 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 #2
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 #3
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());
	}
}