2

Mnemonic mode does not change on e. g. ALT pressed when an editable Spinner is focused. How to fix it? Thank you.

Minimal, Reproducible Example:

package org.example;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Spinner;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class EditableSpinnerMnemonicTestApp extends Application {

    @Override
    public void start(Stage stage) {

        Spinner<Integer>
                spinner = new Spinner<>(0, 0, 0),
                editableSpinner = new Spinner<>(0, 0, 0);

        spinner.setEditable(false); // (default) Mnemonic mode changes when focused and ALT pressed
        editableSpinner.setEditable(true); // Nothing happens when focused and ALT pressed

        Label label = new Label("_Test");
        label.setMnemonicParsing(true);
        label.setLabelFor(spinner);
        label.setPadding(new Insets(0,0,3,0));

        stage.setScene(new Scene(new VBox(label, spinner, editableSpinner)));
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}
anko
  • 1,628
  • 1
  • 6
  • 14
  • What is your OS platform? Is it Windows or Mac? [mnemonics are not supported on Mac](https://stackoverflow.com/questions/24499500/javafx-menu-first-letter-underline-decoration). Also, what is your JavaFX version? Potentially there were some [regressions in the mnemonic handling with Java 17](https://www.reddit.com/r/JavaFX/comments/pwfmq2/mnemonic_parsing_in_openjfx_17/). – jewelsea Oct 13 '21 at 23:42
  • Windows with JavaFX 17. Just tested JavaFX 11, 16, 18-ea+4 and it did not work as well. Is it possible to “manually” toggle the mnemonic mode by adding an EventFilter for the editable Spinner or its Editor? – anko Oct 14 '21 at 01:37
  • hmm .. worksforme, provided I set the labelFor to the editableSpinner - is not doing so an oversight in this code example only or also in your project? But then, re-reading your description: all underscores indeed don't change if the editable spinner is focused. – kleopatra Oct 14 '21 at 12:07
  • 1
    same for editable combo .. all in win10 with fx17+ and fx11. Looks like the editable spinner/combo swallow the alt for some reason .. you might consider filing an issue :) – kleopatra Oct 14 '21 at 12:19

0 Answers0