Re: Accelerators - odd behavior
I must correct that, KeyCharacterCombination("+", KeyCombination.CONTROL_DOWN) is the same as KeyCharacterCombination("=", KeyCombination.CONTROL_DOWN) (on a US keyboard). It only works if you *don't* also press shift to get the "+" character. On Fri, Sep 26, 2014 at 6:58 PM, Scott Palmer wrote: > While looking into this I noticed that KeyCharacterCombination("+", > KeyCombination.CONTROL_DOWN) doesn't work for either the PLUS (shifted > EQUALS), or ADD (numeric keypad "+"). > > Only KeyCodeCombintation(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, > KeyCombination.SHIFT_DOWN) > was working. > > On Fri, Sep 26, 2014 at 3:11 PM, Tomas Mikula > wrote: > >> > That doesn't explain why this isn't happening for PLUS. >> >> KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) >> >> is never matched. It might even be impossible to get a KEY_PRESSED >> event with key code PLUS with English keyboard layout. When I switch >> keyboard layout to Slovak, which has the '+' sign accessible without >> Shift, I do get the runnable fired twice. >> >> Best, >> Tomas >> > >
Re: Accelerators - odd behavior
I should note that KeyCodeCombintation(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN) is undesirable as it requires knowledge of the keyboard layout that shouldn't be required. On Fri, Sep 26, 2014 at 6:58 PM, Scott Palmer wrote: > While looking into this I noticed that KeyCharacterCombination("+", > KeyCombination.CONTROL_DOWN) doesn't work for either the PLUS (shifted > EQUALS), or ADD (numeric keypad "+"). > > Only KeyCodeCombintation(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, > KeyCombination.SHIFT_DOWN) > was working. > > On Fri, Sep 26, 2014 at 3:11 PM, Tomas Mikula > wrote: > >> > That doesn't explain why this isn't happening for PLUS. >> >> KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) >> >> is never matched. It might even be impossible to get a KEY_PRESSED >> event with key code PLUS with English keyboard layout. When I switch >> keyboard layout to Slovak, which has the '+' sign accessible without >> Shift, I do get the runnable fired twice. >> >> Best, >> Tomas >> > >
Re: Accelerators - odd behavior
While looking into this I noticed that KeyCharacterCombination("+", KeyCombination.CONTROL_DOWN) doesn't work for either the PLUS (shifted EQUALS), or ADD (numeric keypad "+"). Only KeyCodeCombintation(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN) was working. On Fri, Sep 26, 2014 at 3:11 PM, Tomas Mikula wrote: > > That doesn't explain why this isn't happening for PLUS. > > KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) > > is never matched. It might even be impossible to get a KEY_PRESSED > event with key code PLUS with English keyboard layout. When I switch > keyboard layout to Slovak, which has the '+' sign accessible without > Shift, I do get the runnable fired twice. > > Best, > Tomas >
Re: Accelerators - odd behavior
Can you add this information to the JIRA? https://javafx-jira.kenai.com/browse/RT-38830 Thanks. -- Kevin Tomas Mikula wrote: Anyway, the algorithm used in KeyCharacterCombination looks odd to me. What it does is it tries to find a key code capable of producing the character and then compares it to the event's key code. It would make more sense to me if it took the event, converted it to a character it produced and then compare the characters. This way your first attempt to capture both MINUS and SUBTRACT with a single KeyCharacterCombination("-") would work, as well as capturing all of Shift-EQUALS, PLUS, ADD with a single KeyCharacterCombination("+"). Tomas On Fri, Sep 26, 2014 at 9:11 PM, Tomas Mikula wrote: That doesn't explain why this isn't happening for PLUS. KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) is never matched. It might even be impossible to get a KEY_PRESSED event with key code PLUS with English keyboard layout. When I switch keyboard layout to Slovak, which has the '+' sign accessible without Shift, I do get the runnable fired twice. Best, Tomas
Re: Accelerators - odd behavior
Anyway, the algorithm used in KeyCharacterCombination looks odd to me. What it does is it tries to find a key code capable of producing the character and then compares it to the event's key code. It would make more sense to me if it took the event, converted it to a character it produced and then compare the characters. This way your first attempt to capture both MINUS and SUBTRACT with a single KeyCharacterCombination("-") would work, as well as capturing all of Shift-EQUALS, PLUS, ADD with a single KeyCharacterCombination("+"). Tomas On Fri, Sep 26, 2014 at 9:11 PM, Tomas Mikula wrote: >> That doesn't explain why this isn't happening for PLUS. > > KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) > > is never matched. It might even be impossible to get a KEY_PRESSED > event with key code PLUS with English keyboard layout. When I switch > keyboard layout to Slovak, which has the '+' sign accessible without > Shift, I do get the runnable fired twice. > > Best, > Tomas
Re: Accelerators - odd behavior
> That doesn't explain why this isn't happening for PLUS. KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN) is never matched. It might even be impossible to get a KEY_PRESSED event with key code PLUS with English keyboard layout. When I switch keyboard layout to Slovak, which has the '+' sign accessible without Shift, I do get the runnable fired twice. Best, Tomas
Re: Accelerators - odd behavior
That doesn't explain why this isn't happening for PLUS. On Fri, Sep 26, 2014 at 2:05 PM, Tomas Mikula wrote: > The cause of the problem seems clear to me. This is what I observe on > my (Linux) system. > > Pressing '-' on the main part of the keyboard produces MINUS key code > pressed. Pressing '-' on the numeric keypad produces SUBTRACT key code > pressed. > > KeyCharacterCombination("-") matches MINUS pressed, but does not match > SUBTRACT pressed (this is the part that may vary across systems, I > think. If on Mac it match SUBTRACT and not MINUS, it explains the > problem). > > So in Scott's test case, when I press ordinary minus, MINUS pressed > event is fired, and both KeyCodeCombination(MINUS) and > KeyCharacterCombination("-") match, so the runnable is executed twice. > > When, on the other hand, I pres minus on numeric keypad, SUBTRACT > pressed event is fired, and only KeyCodeCombination(SUBTRACT) matches, > so the runnable is executed only once. > > To test this explanation, can someone please run the following program > on a Mac and post its output? > > > import static javafx.scene.input.KeyCode.*; > import static javafx.scene.input.KeyEvent.*; > import javafx.application.Platform; > import javafx.embed.swing.JFXPanel; > import javafx.scene.input.KeyCharacterCombination; > import javafx.scene.input.KeyEvent; > > > public class KeyCodeForMinus { > > public static void main(String[] args) { > new JFXPanel(); > > KeyCharacterCombination minusChar = new > KeyCharacterCombination("-"); > KeyEvent minusPressed = new KeyEvent(KEY_PRESSED, "", "", > MINUS, false, false, false, false); > KeyEvent subtractPressed = new KeyEvent(KEY_PRESSED, "", "", > SUBTRACT, false, false, false, false); > > System.out.println("'-' matches MINUS: " + > minusChar.match(minusPressed)); > System.out.println("'-' matches SUBTRACT: " + > minusChar.match(subtractPressed)); > > Platform.exit(); > } > > } > > On Fri, Sep 26, 2014 at 7:44 PM, Scott Palmer wrote: > > Please attach the test case I mailed earlier to the JIRA issue. > > > > On Fri, Sep 26, 2014 at 1:42 PM, Stephen F Northover < > > steve.x.northo...@oracle.com> wrote: > > > >> Agree. Suggest that we move the discussion to the JIRA to capture the > >> background information for whoever will address the bug. > >> > >> Steve > >> > >> > >> On 2014-09-26, 1:41 PM, Kevin Rushforth wrote: > >> > >>> It may or may not be a bug, but it will be good to investigate. > >>> > >>> -- Kevin > >>> > >>> > >>> Stephen F Northover wrote: > >>> > Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ > browse/RT-38830 > > Steve > > On 2014-09-26, 1:25 PM, Stephen F Northover wrote: > > > This is on Mac. Will try Windows. > > > > Steve > > > > On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: > > > >> Is this on a Mac or on Windows? I just ran your test case and I get > >> two runnables, which is what I would expect. > >> > >> -- Kevin > >> > >> > >> Stephen F Northover wrote: > >> > >>> I am only seeing the runnable fired once in FX 8u40. > >>> > >>> Steve > >>> > >>> Steps: > >>> > >>> 1) Run TestKeyCombination > >>> 2) Press Control+- > >>> > >>> Here is the test code: > >>> > >>> import javafx.application.Application; > >>> import javafx.scene.Group; > >>> import javafx.scene.Scene; > >>> import javafx.scene.control.Button; > >>> import javafx.scene.input.KeyCharacterCombination; > >>> import javafx.scene.input.KeyCode; > >>> import javafx.scene.input.KeyCodeCombination; > >>> import javafx.scene.input.KeyCombination; > >>> import javafx.stage.Stage; > >>> > >>> public class TestKeyCombination extends Application { > >>> public static void main(String[] args) { > >>> Application.launch(args); > >>> } > >>> > >>> @Override public void start(Stage stage) { > >>> stage.setTitle("Test KeyCombination"); > >>> Scene scene = new Scene(new Group(), 600, 450); > >>> Button button1 = new Button(); > >>> button1.setText("Click Me"); > >>> stage.setScene(scene); > >>> stage.show(); > >>> > >>> KeyCombination cmdMinus = new > KeyCodeCombination(KeyCode.MINUS, > >>> KeyCombination.CONTROL_DOWN); > >>> KeyCombination cmdMinusFromCharacter = new > >>> KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); > >>> Runnable runnable = () -> System.out.println("HI"); > >>> scene.getAccelerators().put(cmdMinus, runnable); > >>> scene.getAccelerators().put(cmdMinusFromCharacter, > runnable); > >>> } > >>> } > >>> > >>> > >>> On 2014-09-26, 1:01 PM, Scott Palmer wrote: > >>> > KeyCombination cmdMinus = new Key*Code*Combination(KeyCod
In(Sanity) Testing Mondays
Reminder, Monday is our weekly sanity testing. We will be light this week due to JavaOne, but if you are not attending the conference please do your sanity testing :) You can find your testing assignment at: https://wiki.openjdk.java.net/display/OpenJFX/Sanity+Testing Also please remember that the repo will be locked from 1am PDT until 1pm PDT. Happy testing! Lisa
Re: Accelerators - odd behavior
Here is a possible solution to Scott's original problem: KeyCombination CtrlMinus = new KeyCombination(CONTROL_DOWN) { @Override public boolean match(KeyEvent event) { return super.match(event) && event.getEventType() == KEY_PRESSED && (event.getCode() == MINUS || event.getCode() == SUBTRACT); } }; menuItem.setAccelerator(CtrlMinus); On Fri, Sep 26, 2014 at 8:05 PM, Tomas Mikula wrote: > The cause of the problem seems clear to me. This is what I observe on > my (Linux) system. > > Pressing '-' on the main part of the keyboard produces MINUS key code > pressed. Pressing '-' on the numeric keypad produces SUBTRACT key code > pressed. > > KeyCharacterCombination("-") matches MINUS pressed, but does not match > SUBTRACT pressed (this is the part that may vary across systems, I > think. If on Mac it match SUBTRACT and not MINUS, it explains the > problem). > > So in Scott's test case, when I press ordinary minus, MINUS pressed > event is fired, and both KeyCodeCombination(MINUS) and > KeyCharacterCombination("-") match, so the runnable is executed twice. > > When, on the other hand, I pres minus on numeric keypad, SUBTRACT > pressed event is fired, and only KeyCodeCombination(SUBTRACT) matches, > so the runnable is executed only once. > > To test this explanation, can someone please run the following program > on a Mac and post its output? > > > import static javafx.scene.input.KeyCode.*; > import static javafx.scene.input.KeyEvent.*; > import javafx.application.Platform; > import javafx.embed.swing.JFXPanel; > import javafx.scene.input.KeyCharacterCombination; > import javafx.scene.input.KeyEvent; > > > public class KeyCodeForMinus { > > public static void main(String[] args) { > new JFXPanel(); > > KeyCharacterCombination minusChar = new KeyCharacterCombination("-"); > KeyEvent minusPressed = new KeyEvent(KEY_PRESSED, "", "", > MINUS, false, false, false, false); > KeyEvent subtractPressed = new KeyEvent(KEY_PRESSED, "", "", > SUBTRACT, false, false, false, false); > > System.out.println("'-' matches MINUS: " + > minusChar.match(minusPressed)); > System.out.println("'-' matches SUBTRACT: " + > minusChar.match(subtractPressed)); > > Platform.exit(); > } > > } > > On Fri, Sep 26, 2014 at 7:44 PM, Scott Palmer wrote: >> Please attach the test case I mailed earlier to the JIRA issue. >> >> On Fri, Sep 26, 2014 at 1:42 PM, Stephen F Northover < >> steve.x.northo...@oracle.com> wrote: >> >>> Agree. Suggest that we move the discussion to the JIRA to capture the >>> background information for whoever will address the bug. >>> >>> Steve >>> >>> >>> On 2014-09-26, 1:41 PM, Kevin Rushforth wrote: >>> It may or may not be a bug, but it will be good to investigate. -- Kevin Stephen F Northover wrote: > Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ > browse/RT-38830 > > Steve > > On 2014-09-26, 1:25 PM, Stephen F Northover wrote: > >> This is on Mac. Will try Windows. >> >> Steve >> >> On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: >> >>> Is this on a Mac or on Windows? I just ran your test case and I get >>> two runnables, which is what I would expect. >>> >>> -- Kevin >>> >>> >>> Stephen F Northover wrote: >>> I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().p
Re: Accelerators - odd behavior
The cause of the problem seems clear to me. This is what I observe on my (Linux) system. Pressing '-' on the main part of the keyboard produces MINUS key code pressed. Pressing '-' on the numeric keypad produces SUBTRACT key code pressed. KeyCharacterCombination("-") matches MINUS pressed, but does not match SUBTRACT pressed (this is the part that may vary across systems, I think. If on Mac it match SUBTRACT and not MINUS, it explains the problem). So in Scott's test case, when I press ordinary minus, MINUS pressed event is fired, and both KeyCodeCombination(MINUS) and KeyCharacterCombination("-") match, so the runnable is executed twice. When, on the other hand, I pres minus on numeric keypad, SUBTRACT pressed event is fired, and only KeyCodeCombination(SUBTRACT) matches, so the runnable is executed only once. To test this explanation, can someone please run the following program on a Mac and post its output? import static javafx.scene.input.KeyCode.*; import static javafx.scene.input.KeyEvent.*; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyEvent; public class KeyCodeForMinus { public static void main(String[] args) { new JFXPanel(); KeyCharacterCombination minusChar = new KeyCharacterCombination("-"); KeyEvent minusPressed = new KeyEvent(KEY_PRESSED, "", "", MINUS, false, false, false, false); KeyEvent subtractPressed = new KeyEvent(KEY_PRESSED, "", "", SUBTRACT, false, false, false, false); System.out.println("'-' matches MINUS: " + minusChar.match(minusPressed)); System.out.println("'-' matches SUBTRACT: " + minusChar.match(subtractPressed)); Platform.exit(); } } On Fri, Sep 26, 2014 at 7:44 PM, Scott Palmer wrote: > Please attach the test case I mailed earlier to the JIRA issue. > > On Fri, Sep 26, 2014 at 1:42 PM, Stephen F Northover < > steve.x.northo...@oracle.com> wrote: > >> Agree. Suggest that we move the discussion to the JIRA to capture the >> background information for whoever will address the bug. >> >> Steve >> >> >> On 2014-09-26, 1:41 PM, Kevin Rushforth wrote: >> >>> It may or may not be a bug, but it will be good to investigate. >>> >>> -- Kevin >>> >>> >>> Stephen F Northover wrote: >>> Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ browse/RT-38830 Steve On 2014-09-26, 1:25 PM, Stephen F Northover wrote: > This is on Mac. Will try Windows. > > Steve > > On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: > >> Is this on a Mac or on Windows? I just ran your test case and I get >> two runnables, which is what I would expect. >> >> -- Kevin >> >> >> Stephen F Northover wrote: >> >>> I am only seeing the runnable fired once in FX 8u40. >>> >>> Steve >>> >>> Steps: >>> >>> 1) Run TestKeyCombination >>> 2) Press Control+- >>> >>> Here is the test code: >>> >>> import javafx.application.Application; >>> import javafx.scene.Group; >>> import javafx.scene.Scene; >>> import javafx.scene.control.Button; >>> import javafx.scene.input.KeyCharacterCombination; >>> import javafx.scene.input.KeyCode; >>> import javafx.scene.input.KeyCodeCombination; >>> import javafx.scene.input.KeyCombination; >>> import javafx.stage.Stage; >>> >>> public class TestKeyCombination extends Application { >>> public static void main(String[] args) { >>> Application.launch(args); >>> } >>> >>> @Override public void start(Stage stage) { >>> stage.setTitle("Test KeyCombination"); >>> Scene scene = new Scene(new Group(), 600, 450); >>> Button button1 = new Button(); >>> button1.setText("Click Me"); >>> stage.setScene(scene); >>> stage.show(); >>> >>> KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdMinusFromCharacter = new >>> KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); >>> Runnable runnable = () -> System.out.println("HI"); >>> scene.getAccelerators().put(cmdMinus, runnable); >>> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >>> } >>> } >>> >>> >>> On 2014-09-26, 1:01 PM, Scott Palmer wrote: >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the
Re: Accelerators - odd behavior
Please attach the test case I mailed earlier to the JIRA issue. On Fri, Sep 26, 2014 at 1:42 PM, Stephen F Northover < steve.x.northo...@oracle.com> wrote: > Agree. Suggest that we move the discussion to the JIRA to capture the > background information for whoever will address the bug. > > Steve > > > On 2014-09-26, 1:41 PM, Kevin Rushforth wrote: > >> It may or may not be a bug, but it will be good to investigate. >> >> -- Kevin >> >> >> Stephen F Northover wrote: >> >>> Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ >>> browse/RT-38830 >>> >>> Steve >>> >>> On 2014-09-26, 1:25 PM, Stephen F Northover wrote: >>> This is on Mac. Will try Windows. Steve On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: > Is this on a Mac or on Windows? I just ran your test case and I get > two runnables, which is what I would expect. > > -- Kevin > > > Stephen F Northover wrote: > >> I am only seeing the runnable fired once in FX 8u40. >> >> Steve >> >> Steps: >> >> 1) Run TestKeyCombination >> 2) Press Control+- >> >> Here is the test code: >> >> import javafx.application.Application; >> import javafx.scene.Group; >> import javafx.scene.Scene; >> import javafx.scene.control.Button; >> import javafx.scene.input.KeyCharacterCombination; >> import javafx.scene.input.KeyCode; >> import javafx.scene.input.KeyCodeCombination; >> import javafx.scene.input.KeyCombination; >> import javafx.stage.Stage; >> >> public class TestKeyCombination extends Application { >> public static void main(String[] args) { >> Application.launch(args); >> } >> >> @Override public void start(Stage stage) { >> stage.setTitle("Test KeyCombination"); >> Scene scene = new Scene(new Group(), 600, 450); >> Button button1 = new Button(); >> button1.setText("Click Me"); >> stage.setScene(scene); >> stage.show(); >> >> KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdMinusFromCharacter = new >> KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); >> Runnable runnable = () -> System.out.println("HI"); >> scene.getAccelerators().put(cmdMinus, runnable); >> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >> } >> } >> >> >> On 2014-09-26, 1:01 PM, Scott Palmer wrote: >> >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdMinusFromCharacter = new >>> Key*Character*Combination("-", >>> KeyCombination.CONTROL_DOWN); >>> >>> Using the above like this: >>> scene.getAccelerators().put(cmdMinus, runnable); >>> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >>> >>> Will result in the runnable being fired twice from the same keypress. >>> >>> I propose changing the accelerator processing logic so that only one >>> runnable gets called as the intention appears to be that a >>> KeyCombination >>> can only have one runnable associated with it, but the logic in Map >>> doesn't >>> see the above two KeyCombinations as the same key in the Map. >>> >>> Note: With the second combination above I really wanted something >>> that >>> worked for both MINUS and SUBTRACT simultaneously - since they both >>> type >>> the same Character and only one accelerator can be set on a MenuItem. >>> >>> Scott >>> >> >> >>> >
Re: Accelerators - odd behavior
What started all this was that I sued CTRL +/- to zoom in and out in my app. People found that one press to zoom out needed two presses to zoom back in. If the behavior is platform-specific it will be awkward to deal with. Specially since I want it to work with the numeric keypad as well.. so I need to manually add accelerators to the scene apart from my MenuItem accelerators. Scott On Fri, Sep 26, 2014 at 1:39 PM, Scott Palmer wrote: > Okay.. so what is going on with Windows and CTRL+PLUS ? > > Scott > > On Fri, Sep 26, 2014 at 1:35 PM, Stephen F Northover < > steve.x.northo...@oracle.com> wrote: > >> Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ >> browse/RT-38830 >> >> Steve >> >> >> On 2014-09-26, 1:25 PM, Stephen F Northover wrote: >> >>> This is on Mac. Will try Windows. >>> >>> Steve >>> >>> On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: >>> Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: > I am only seeing the runnable fired once in FX 8u40. > > Steve > > Steps: > > 1) Run TestKeyCombination > 2) Press Control+- > > Here is the test code: > > import javafx.application.Application; > import javafx.scene.Group; > import javafx.scene.Scene; > import javafx.scene.control.Button; > import javafx.scene.input.KeyCharacterCombination; > import javafx.scene.input.KeyCode; > import javafx.scene.input.KeyCodeCombination; > import javafx.scene.input.KeyCombination; > import javafx.stage.Stage; > > public class TestKeyCombination extends Application { > public static void main(String[] args) { > Application.launch(args); > } > > @Override public void start(Stage stage) { > stage.setTitle("Test KeyCombination"); > Scene scene = new Scene(new Group(), 600, 450); > Button button1 = new Button(); > button1.setText("Click Me"); > stage.setScene(scene); > stage.show(); > > KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, > KeyCombination.CONTROL_DOWN); > KeyCombination cmdMinusFromCharacter = new > KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); > Runnable runnable = () -> System.out.println("HI"); > scene.getAccelerators().put(cmdMinus, runnable); > scene.getAccelerators().put(cmdMinusFromCharacter, runnable); > } > } > > > On 2014-09-26, 1:01 PM, Scott Palmer wrote: > >> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdMinusFromCharacter = new >> Key*Character*Combination("-", >> KeyCombination.CONTROL_DOWN); >> >> Using the above like this: >> scene.getAccelerators().put(cmdMinus, runnable); >> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >> >> Will result in the runnable being fired twice from the same keypress. >> >> I propose changing the accelerator processing logic so that only one >> runnable gets called as the intention appears to be that a >> KeyCombination >> can only have one runnable associated with it, but the logic in Map >> doesn't >> see the above two KeyCombinations as the same key in the Map. >> >> Note: With the second combination above I really wanted something that >> worked for both MINUS and SUBTRACT simultaneously - since they both >> type >> the same Character and only one accelerator can be set on a MenuItem. >> >> Scott >> > > >>> >> >
Re: Accelerators - odd behavior
Agree. Suggest that we move the discussion to the JIRA to capture the background information for whoever will address the bug. Steve On 2014-09-26, 1:41 PM, Kevin Rushforth wrote: It may or may not be a bug, but it will be good to investigate. -- Kevin Stephen F Northover wrote: Two on Windows, one on Mac. See https://javafx-jira.kenai.com/browse/RT-38830 Steve On 2014-09-26, 1:25 PM, Stephen F Northover wrote: This is on Mac. Will try Windows. Steve On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
> Why does a Scene accelerator Map take runnables instead of EventHandlers ? That's a good question. It's been that way since it was initially introduced in FX 2.0, and it seems at odds with the way other events are handled. -- Kevin Scott Palmer wrote: While we are on the subject... Why does a Scene accelerator Map take runnables instead of EventHandlers ? Scott On Fri, Sep 26, 2014 at 1:27 PM, Scott Palmer wrote: Forgot to include the list. (I'm testing with 8u20 btw) -- Forwarded message -- From: Scott Palmer Date: Fri, Sep 26, 2014 at 1:25 PM Subject: Re: Accelerators - odd behavior To: Kevin Rushforth Yes, for CTRL+a I do see it fire twice. On Fri, Sep 26, 2014 at 1:21 PM, Kevin Rushforth < kevin.rushfo...@oracle.com> wrote: This does seem somewhat strange. Do you get multiple calls to your runnable if you use a KeyCharacter combination and KeyCode combination for CTRL-a or other key that generates a key char without needing a shift? -- Kevin Scott Palmer wrote: What is very interesting about this is that I can't duplicate it with the "+" character. I've added all of the following to the scene accelerators and it still only fires my "plus" action once for each press. KeyCombination cmdPlus = new KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdAdd = new KeyCodeCombination(KeyCode.ADD, KeyCombination.CONTROL_DOWN); KeyCombination cmdPlusAsShiftEquals = new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, KeyCodeCombination.SHIFT_DOWN); KeyCombination cmdPlusFromCharacter = new KeyCharacterCombination("+", KeyCombination.CONTROL_DOWN); This is weird. On Fri, Sep 26, 2014 at 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
It may or may not be a bug, but it will be good to investigate. -- Kevin Stephen F Northover wrote: Two on Windows, one on Mac. See https://javafx-jira.kenai.com/browse/RT-38830 Steve On 2014-09-26, 1:25 PM, Stephen F Northover wrote: This is on Mac. Will try Windows. Steve On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
Okay.. so what is going on with Windows and CTRL+PLUS ? Scott On Fri, Sep 26, 2014 at 1:35 PM, Stephen F Northover < steve.x.northo...@oracle.com> wrote: > Two on Windows, one on Mac. See https://javafx-jira.kenai.com/ > browse/RT-38830 > > Steve > > > On 2014-09-26, 1:25 PM, Stephen F Northover wrote: > >> This is on Mac. Will try Windows. >> >> Steve >> >> On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: >> >>> Is this on a Mac or on Windows? I just ran your test case and I get two >>> runnables, which is what I would expect. >>> >>> -- Kevin >>> >>> >>> Stephen F Northover wrote: >>> I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: > KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, > KeyCombination.CONTROL_DOWN); > KeyCombination cmdMinusFromCharacter = new > Key*Character*Combination("-", > KeyCombination.CONTROL_DOWN); > > Using the above like this: > scene.getAccelerators().put(cmdMinus, runnable); > scene.getAccelerators().put(cmdMinusFromCharacter, runnable); > > Will result in the runnable being fired twice from the same keypress. > > I propose changing the accelerator processing logic so that only one > runnable gets called as the intention appears to be that a > KeyCombination > can only have one runnable associated with it, but the logic in Map > doesn't > see the above two KeyCombinations as the same key in the Map. > > Note: With the second combination above I really wanted something that > worked for both MINUS and SUBTRACT simultaneously - since they both > type > the same Character and only one accelerator can be set on a MenuItem. > > Scott > >> >
Re: Accelerators - odd behavior
Two on Windows, one on Mac. See https://javafx-jira.kenai.com/browse/RT-38830 Steve On 2014-09-26, 1:25 PM, Stephen F Northover wrote: This is on Mac. Will try Windows. Steve On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
Attached my test case... On Fri, Sep 26, 2014 at 1:31 PM, Scott Palmer wrote: > That would imply that 8u40 is broken (where '-' only fired once for > Stephen), or it's broken for the + key. > > Scott > > On Fri, Sep 26, 2014 at 1:29 PM, Kevin Rushforth < > kevin.rushfo...@oracle.com> wrote: > >> >> "This means that the method can return true only for KEY_PRESSED >> andKEY_RELEASED events, but not for KEY_TYPED events, which don't have >> valid key codes." >> >> >> Ah, I missed that. I would expect such a disclaimer for >> KeyCodeCombination but not for KeyTypedCombination. In any case, it still >> seems correct that two events are produced for the particular test case in >> question. >> >> -- Kevin >> >> >> >> Tomas Mikula wrote: >> >> Hi Kevin, >> >> >> On Fri, Sep 26, 2014 at 7:16 PM, Kevin Rushforth >> wrote: >> >> >> It seems to me that this is working as designed. You have created two >> different KeyCombinations and asked that both fire your runnable. Further, >> both of the KeyCombinations match your key input since both a KeyPressed and >> a KeyTyped event are sent when pressing a key that has an associated >> character. I'm not sure how we could change it in a way that wouldn't be >> surprising or difficult to specify or document. >> >> >> The Javadoc for KeyCharacterCombination#match also says >> >> "This means that the method can return true only for KEY_PRESSED >> andKEY_RELEASED events, but not for KEY_TYPED events, which don't have >> valid key codes." >> >> Thus it is probably not related to KEY_TYPED events. >> >> Tomas >> >> >> >> -- Kevin >> >> >> >> Scott Palmer wrote: >> >> >> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", >> KeyCombination.CONTROL_DOWN); >> >> Using the above like this: >> scene.getAccelerators().put(cmdMinus, runnable); >> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >> >> Will result in the runnable being fired twice from the same keypress. >> >> I propose changing the accelerator processing logic so that only one >> runnable gets called as the intention appears to be that a KeyCombination >> can only have one runnable associated with it, but the logic in Map >> doesn't >> see the above two KeyCombinations as the same key in the Map. >> >> Note: With the second combination above I really wanted something that >> worked for both MINUS and SUBTRACT simultaneously - since they both type >> the same Character and only one accelerator can be set on a MenuItem. >> >> Scott >> >> >> >> >
Re: Accelerators - odd behavior
That would imply that 8u40 is broken (where '-' only fired once for Stephen), or it's broken for the + key. Scott On Fri, Sep 26, 2014 at 1:29 PM, Kevin Rushforth wrote: > > "This means that the method can return true only for KEY_PRESSED > andKEY_RELEASED events, but not for KEY_TYPED events, which don't have > valid key codes." > > > Ah, I missed that. I would expect such a disclaimer for KeyCodeCombination > but not for KeyTypedCombination. In any case, it still seems correct that > two events are produced for the particular test case in question. > > -- Kevin > > > > Tomas Mikula wrote: > > Hi Kevin, > > > On Fri, Sep 26, 2014 at 7:16 PM, Kevin Rushforth > wrote: > > > It seems to me that this is working as designed. You have created two > different KeyCombinations and asked that both fire your runnable. Further, > both of the KeyCombinations match your key input since both a KeyPressed and > a KeyTyped event are sent when pressing a key that has an associated > character. I'm not sure how we could change it in a way that wouldn't be > surprising or difficult to specify or document. > > > The Javadoc for KeyCharacterCombination#match also says > > "This means that the method can return true only for KEY_PRESSED > andKEY_RELEASED events, but not for KEY_TYPED events, which don't have > valid key codes." > > Thus it is probably not related to KEY_TYPED events. > > Tomas > > > > -- Kevin > > > > Scott Palmer wrote: > > > KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, > KeyCombination.CONTROL_DOWN); > KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", > KeyCombination.CONTROL_DOWN); > > Using the above like this: > scene.getAccelerators().put(cmdMinus, runnable); > scene.getAccelerators().put(cmdMinusFromCharacter, runnable); > > Will result in the runnable being fired twice from the same keypress. > > I propose changing the accelerator processing logic so that only one > runnable gets called as the intention appears to be that a KeyCombination > can only have one runnable associated with it, but the logic in Map > doesn't > see the above two KeyCombinations as the same key in the Map. > > Note: With the second combination above I really wanted something that > worked for both MINUS and SUBTRACT simultaneously - since they both type > the same Character and only one accelerator can be set on a MenuItem. > > Scott > > > >
Re: Accelerators - odd behavior
"This means that the method can return true only for KEY_PRESSED andKEY_RELEASED events, but not for KEY_TYPED events, which don't have valid key codes." Ah, I missed that. I would expect such a disclaimer for KeyCodeCombination but not for KeyTypedCombination. In any case, it still seems correct that two events are produced for the particular test case in question. -- Kevin Tomas Mikula wrote: Hi Kevin, On Fri, Sep 26, 2014 at 7:16 PM, Kevin Rushforth wrote: It seems to me that this is working as designed. You have created two different KeyCombinations and asked that both fire your runnable. Further, both of the KeyCombinations match your key input since both a KeyPressed and a KeyTyped event are sent when pressing a key that has an associated character. I'm not sure how we could change it in a way that wouldn't be surprising or difficult to specify or document. The Javadoc for KeyCharacterCombination#match also says "This means that the method can return true only for KEY_PRESSED andKEY_RELEASED events, but not for KEY_TYPED events, which don't have valid key codes." Thus it is probably not related to KEY_TYPED events. Tomas -- Kevin Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
While we are on the subject... Why does a Scene accelerator Map take runnables instead of EventHandlers ? Scott On Fri, Sep 26, 2014 at 1:27 PM, Scott Palmer wrote: > Forgot to include the list. > > (I'm testing with 8u20 btw) > > -- Forwarded message -- > From: Scott Palmer > Date: Fri, Sep 26, 2014 at 1:25 PM > Subject: Re: Accelerators - odd behavior > To: Kevin Rushforth > > > Yes, for CTRL+a I do see it fire twice. > > On Fri, Sep 26, 2014 at 1:21 PM, Kevin Rushforth < > kevin.rushfo...@oracle.com> wrote: > >> This does seem somewhat strange. Do you get multiple calls to your >> runnable if you use a KeyCharacter combination and KeyCode combination for >> CTRL-a or other key that generates a key char without needing a shift? >> >> -- Kevin >> >> >> Scott Palmer wrote: >> >>> What is very interesting about this is that I can't duplicate it with the >>> "+" character. >>> I've added all of the following to the scene accelerators and it still >>> only >>> fires my "plus" action once for each press. >>> >>> KeyCombination cmdPlus = new KeyCodeCombination(KeyCode.PLUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdAdd = new KeyCodeCombination(KeyCode.ADD, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdPlusAsShiftEquals = new >>> KeyCodeCombination(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, >>> KeyCodeCombination.SHIFT_DOWN); >>> KeyCombination cmdPlusFromCharacter = new KeyCharacterCombination("+", >>> KeyCombination.CONTROL_DOWN); >>> >>> This is weird. >>> >>> On Fri, Sep 26, 2014 at 1:01 PM, Scott Palmer >>> wrote: >>> >>> >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott >>> > >
Re: Accelerators - odd behavior
The explanation could be that on some systems the KeyCharacterCombination("-").match picks the same key code as the one produced by key press (e.g. MINUS), while on other systems it picks the other one (SUBTRACT). On Fri, Sep 26, 2014 at 7:24 PM, Kevin Rushforth wrote: > Is this on a Mac or on Windows? I just ran your test case and I get two > runnables, which is what I would expect. > > -- Kevin > > > > Stephen F Northover wrote: >> >> I am only seeing the runnable fired once in FX 8u40. >> >> Steve >> >> Steps: >> >> 1) Run TestKeyCombination >> 2) Press Control+- >> >> Here is the test code: >> >> import javafx.application.Application; >> import javafx.scene.Group; >> import javafx.scene.Scene; >> import javafx.scene.control.Button; >> import javafx.scene.input.KeyCharacterCombination; >> import javafx.scene.input.KeyCode; >> import javafx.scene.input.KeyCodeCombination; >> import javafx.scene.input.KeyCombination; >> import javafx.stage.Stage; >> >> public class TestKeyCombination extends Application { >> public static void main(String[] args) { >> Application.launch(args); >> } >> >> @Override public void start(Stage stage) { >> stage.setTitle("Test KeyCombination"); >> Scene scene = new Scene(new Group(), 600, 450); >> Button button1 = new Button(); >> button1.setText("Click Me"); >> stage.setScene(scene); >> stage.show(); >> >> KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdMinusFromCharacter = new >> KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); >> Runnable runnable = () -> System.out.println("HI"); >> scene.getAccelerators().put(cmdMinus, runnable); >> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >> } >> } >> >> >> On 2014-09-26, 1:01 PM, Scott Palmer wrote: >>> >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", >>> KeyCombination.CONTROL_DOWN); >>> >>> Using the above like this: >>> scene.getAccelerators().put(cmdMinus, runnable); >>> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >>> >>> Will result in the runnable being fired twice from the same keypress. >>> >>> I propose changing the accelerator processing logic so that only one >>> runnable gets called as the intention appears to be that a KeyCombination >>> can only have one runnable associated with it, but the logic in Map >>> doesn't >>> see the above two KeyCombinations as the same key in the Map. >>> >>> Note: With the second combination above I really wanted something that >>> worked for both MINUS and SUBTRACT simultaneously - since they both type >>> the same Character and only one accelerator can be set on a MenuItem. >>> >>> Scott >> >> >
Fwd: Accelerators - odd behavior
Forgot to include the list. (I'm testing with 8u20 btw) -- Forwarded message -- From: Scott Palmer Date: Fri, Sep 26, 2014 at 1:25 PM Subject: Re: Accelerators - odd behavior To: Kevin Rushforth Yes, for CTRL+a I do see it fire twice. On Fri, Sep 26, 2014 at 1:21 PM, Kevin Rushforth wrote: > This does seem somewhat strange. Do you get multiple calls to your > runnable if you use a KeyCharacter combination and KeyCode combination for > CTRL-a or other key that generates a key char without needing a shift? > > -- Kevin > > > Scott Palmer wrote: > >> What is very interesting about this is that I can't duplicate it with the >> "+" character. >> I've added all of the following to the scene accelerators and it still >> only >> fires my "plus" action once for each press. >> >> KeyCombination cmdPlus = new KeyCodeCombination(KeyCode.PLUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdAdd = new KeyCodeCombination(KeyCode.ADD, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdPlusAsShiftEquals = new >> KeyCodeCombination(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, >> KeyCodeCombination.SHIFT_DOWN); >> KeyCombination cmdPlusFromCharacter = new KeyCharacterCombination("+", >> KeyCombination.CONTROL_DOWN); >> >> This is weird. >> >> On Fri, Sep 26, 2014 at 1:01 PM, Scott Palmer wrote: >> >> >> >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", >>> KeyCombination.CONTROL_DOWN); >>> >>> Using the above like this: >>> scene.getAccelerators().put(cmdMinus, runnable); >>> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >>> >>> Will result in the runnable being fired twice from the same keypress. >>> >>> I propose changing the accelerator processing logic so that only one >>> runnable gets called as the intention appears to be that a KeyCombination >>> can only have one runnable associated with it, but the logic in Map >>> doesn't >>> see the above two KeyCombinations as the same key in the Map. >>> >>> Note: With the second combination above I really wanted something that >>> worked for both MINUS and SUBTRACT simultaneously - since they both type >>> the same Character and only one accelerator can be set on a MenuItem. >>> >>> Scott >>> >>> >>> >>> >>
Re: Accelerators - odd behavior
I'm on Windows 7. On Fri, Sep 26, 2014 at 1:25 PM, Stephen F Northover < steve.x.northo...@oracle.com> wrote: > This is on Mac. Will try Windows. > > Steve > > > On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: > >> Is this on a Mac or on Windows? I just ran your test case and I get two >> runnables, which is what I would expect. >> >> -- Kevin >> >> >> Stephen F Northover wrote: >> >>> I am only seeing the runnable fired once in FX 8u40. >>> >>> Steve >>> >>> Steps: >>> >>> 1) Run TestKeyCombination >>> 2) Press Control+- >>> >>> Here is the test code: >>> >>> import javafx.application.Application; >>> import javafx.scene.Group; >>> import javafx.scene.Scene; >>> import javafx.scene.control.Button; >>> import javafx.scene.input.KeyCharacterCombination; >>> import javafx.scene.input.KeyCode; >>> import javafx.scene.input.KeyCodeCombination; >>> import javafx.scene.input.KeyCombination; >>> import javafx.stage.Stage; >>> >>> public class TestKeyCombination extends Application { >>> public static void main(String[] args) { >>> Application.launch(args); >>> } >>> >>> @Override public void start(Stage stage) { >>> stage.setTitle("Test KeyCombination"); >>> Scene scene = new Scene(new Group(), 600, 450); >>> Button button1 = new Button(); >>> button1.setText("Click Me"); >>> stage.setScene(scene); >>> stage.show(); >>> >>> KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, >>> KeyCombination.CONTROL_DOWN); >>> KeyCombination cmdMinusFromCharacter = new >>> KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); >>> Runnable runnable = () -> System.out.println("HI"); >>> scene.getAccelerators().put(cmdMinus, runnable); >>> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >>> } >>> } >>> >>> >>> On 2014-09-26, 1:01 PM, Scott Palmer wrote: >>> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott >>> >>> >
Re: Accelerators - odd behavior
This is on Mac. Will try Windows. Steve On 2014-09-26, 1:24 PM, Kevin Rushforth wrote: Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
Hi Kevin, On Fri, Sep 26, 2014 at 7:16 PM, Kevin Rushforth wrote: > It seems to me that this is working as designed. You have created two > different KeyCombinations and asked that both fire your runnable. Further, > both of the KeyCombinations match your key input since both a KeyPressed and > a KeyTyped event are sent when pressing a key that has an associated > character. I'm not sure how we could change it in a way that wouldn't be > surprising or difficult to specify or document. The Javadoc for KeyCharacterCombination#match also says "This means that the method can return true only for KEY_PRESSED andKEY_RELEASED events, but not for KEY_TYPED events, which don't have valid key codes." Thus it is probably not related to KEY_TYPED events. Tomas > > -- Kevin > > > > Scott Palmer wrote: >> >> KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, >> KeyCombination.CONTROL_DOWN); >> KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", >> KeyCombination.CONTROL_DOWN); >> >> Using the above like this: >> scene.getAccelerators().put(cmdMinus, runnable); >> scene.getAccelerators().put(cmdMinusFromCharacter, runnable); >> >> Will result in the runnable being fired twice from the same keypress. >> >> I propose changing the accelerator processing logic so that only one >> runnable gets called as the intention appears to be that a KeyCombination >> can only have one runnable associated with it, but the logic in Map >> doesn't >> see the above two KeyCombinations as the same key in the Map. >> >> Note: With the second combination above I really wanted something that >> worked for both MINUS and SUBTRACT simultaneously - since they both type >> the same Character and only one accelerator can be set on a MenuItem. >> >> Scott >>
Re: Accelerators - odd behavior
Is this on a Mac or on Windows? I just ran your test case and I get two runnables, which is what I would expect. -- Kevin Stephen F Northover wrote: I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
Hi Scott, On Fri, Sep 26, 2014 at 7:01 PM, Scott Palmer wrote: > Note: With the second combination above I really wanted something that > worked for both MINUS and SUBTRACT simultaneously - since they both type > the same Character and only one accelerator can be set on a MenuItem. according to Javadoc for KeyCharacterCombination#match (which I was recently reminded to read), this would not work anyway, since "The key character of this object is first translated to the key code which is capable of producing the character in the current keyboard layout and then the resulting key code together with the modifier keys are matched against the key code and key modifiers from the KeyEvent." It seems it just arbitrarily picks whatever key code can produce the character. Best, Tomas
Re: Accelerators - odd behavior
I am only seeing the runnable fired once in FX 8u40. Steve Steps: 1) Run TestKeyCombination 2) Press Control+- Here is the test code: import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.input.KeyCharacterCombination; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.stage.Stage; public class TestKeyCombination extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { stage.setTitle("Test KeyCombination"); Scene scene = new Scene(new Group(), 600, 450); Button button1 = new Button(); button1.setText("Click Me"); stage.setScene(scene); stage.show(); KeyCombination cmdMinus = new KeyCodeCombination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new KeyCharacterCombination("-", KeyCombination.CONTROL_DOWN); Runnable runnable = () -> System.out.println("HI"); scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); } } On 2014-09-26, 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: Accelerators - odd behavior
This does seem somewhat strange. Do you get multiple calls to your runnable if you use a KeyCharacter combination and KeyCode combination for CTRL-a or other key that generates a key char without needing a shift? -- Kevin Scott Palmer wrote: What is very interesting about this is that I can't duplicate it with the "+" character. I've added all of the following to the scene accelerators and it still only fires my "plus" action once for each press. KeyCombination cmdPlus = new KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdAdd = new KeyCodeCombination(KeyCode.ADD, KeyCombination.CONTROL_DOWN); KeyCombination cmdPlusAsShiftEquals = new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, KeyCodeCombination.SHIFT_DOWN); KeyCombination cmdPlusFromCharacter = new KeyCharacterCombination("+", KeyCombination.CONTROL_DOWN); This is weird. On Fri, Sep 26, 2014 at 1:01 PM, Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Re: User Mailing List / Forum
Hi Markus, We have updated the OpenJFX Wiki to point to the right URL for the JavaFX forum: https://community.oracle.com/community/java/javafx/javafx_2.0_and_later Thank you for reporting the problem so we could fix it. -- Kevin Stephen F Northover wrote: This is a good place to ask questions about JFX. I'll look into the broken link. Steve On 2014-09-25, 10:38 AM, Markus Karg wrote: I am new to JavaFX and like to ask if there is some "official" JavaFX 8 forum or mailing list FOR USERS as I did not find this information on http://openjdk.java.net/projects/openjfx/ (actually it says the user forum is https://forums.oracle.com/forums/forum.jspa?forumID=1385 but that results in 404 NOT FOUND! Thanks -Markus
Re: Accelerators - odd behavior
What is very interesting about this is that I can't duplicate it with the "+" character. I've added all of the following to the scene accelerators and it still only fires my "plus" action once for each press. KeyCombination cmdPlus = new KeyCodeCombination(KeyCode.PLUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdAdd = new KeyCodeCombination(KeyCode.ADD, KeyCombination.CONTROL_DOWN); KeyCombination cmdPlusAsShiftEquals = new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.CONTROL_DOWN, KeyCodeCombination.SHIFT_DOWN); KeyCombination cmdPlusFromCharacter = new KeyCharacterCombination("+", KeyCombination.CONTROL_DOWN); This is weird. On Fri, Sep 26, 2014 at 1:01 PM, Scott Palmer wrote: > KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, > KeyCombination.CONTROL_DOWN); > KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", > KeyCombination.CONTROL_DOWN); > > Using the above like this: > scene.getAccelerators().put(cmdMinus, runnable); > scene.getAccelerators().put(cmdMinusFromCharacter, runnable); > > Will result in the runnable being fired twice from the same keypress. > > I propose changing the accelerator processing logic so that only one > runnable gets called as the intention appears to be that a KeyCombination > can only have one runnable associated with it, but the logic in Map doesn't > see the above two KeyCombinations as the same key in the Map. > > Note: With the second combination above I really wanted something that > worked for both MINUS and SUBTRACT simultaneously - since they both type > the same Character and only one accelerator can be set on a MenuItem. > > Scott > >
Re: Accelerators - odd behavior
It seems to me that this is working as designed. You have created two different KeyCombinations and asked that both fire your runnable. Further, both of the KeyCombinations match your key input since both a KeyPressed and a KeyTyped event are sent when pressing a key that has an associated character. I'm not sure how we could change it in a way that wouldn't be surprising or difficult to specify or document. -- Kevin Scott Palmer wrote: KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott
Accelerators - odd behavior
KeyCombination cmdMinus = new Key*Code*Combination(KeyCode.MINUS, KeyCombination.CONTROL_DOWN); KeyCombination cmdMinusFromCharacter = new Key*Character*Combination("-", KeyCombination.CONTROL_DOWN); Using the above like this: scene.getAccelerators().put(cmdMinus, runnable); scene.getAccelerators().put(cmdMinusFromCharacter, runnable); Will result in the runnable being fired twice from the same keypress. I propose changing the accelerator processing logic so that only one runnable gets called as the intention appears to be that a KeyCombination can only have one runnable associated with it, but the logic in Map doesn't see the above two KeyCombinations as the same key in the Map. Note: With the second combination above I really wanted something that worked for both MINUS and SUBTRACT simultaneously - since they both type the same Character and only one accelerator can be set on a MenuItem. Scott