> 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 <swpal...@gmail.com> wrote:

Forgot to include the list.

(I'm testing with 8u20 btw)

---------- Forwarded message ----------
From: Scott Palmer <swpal...@gmail.com>
Date: Fri, Sep 26, 2014 at 1:25 PM
Subject: Re: Accelerators - odd behavior
To: Kevin Rushforth <kevin.rushfo...@oracle.com>


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 <swpal...@gmail.com>
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




Reply via email to