public FXGLButton(String text) { super(text); getStyleClass().setAll("fxgl_button"); setFont(FXGLUIConfig.getUIFactory().newFont(22)); setAlignment(Pos.CENTER); setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { //FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuPress()); fire(); } }); // TODO: //setOnMouseEntered(e -> FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuSelect())); //setOnMouseClicked(e -> FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuPress())); }
public FXGLButton(String text) { super(text); getStyleClass().setAll("fxgl_button"); setFont(FXGL.getUIFactory().newFont(22)); setAlignment(Pos.CENTER); setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ENTER) { FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuPress()); fire(); } }); setOnMouseEntered(e -> FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuSelect())); setOnMouseClicked(e -> FXGL.getAudioPlayer().playSound(FXGL.getSettings().getSoundMenuPress())); }
MenuButton(String stringKey) { btn = new FXGLButton(); btn.setAlignment(Pos.CENTER_LEFT); btn.setStyle("-fx-background-color: transparent"); btn.textProperty().bind(localizedStringProperty(stringKey)); p.setMouseTransparent(true); Paint g = new LinearGradient(0, 1, 1, 0.2, true, CycleMethod.NO_CYCLE, new Stop(0.6, Color.color(1, 0.8, 0, 0.34)), new Stop(0.85, Color.color(1, 0.8, 0, 0.74)), new Stop(1, Color.WHITE)); p.fillProperty().bind( Bindings.when(btn.pressedProperty()).then((Paint) Color.color(1, 0.8, 0, 0.75)).otherwise(g) ); p.setStroke(Color.color(0.1, 0.1, 0.1, 0.15)); p.setEffect(new GaussianBlur()); // TODO: hover and/or focused? p.visibleProperty().bind(btn.hoverProperty()); getChildren().addAll(btn, p); }