B4J Question Get Control Key State

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I need to get the state of the keyboard Control Key.

Imagine an application such as:
https://www.b4x.com/android/forum/threads/draw-rectangular-windows-on-image.48961/#post-305560

I want to select the rectangle panes on a mouse click. If the control key is being held down I want to add the selected pane to the selected list, otherwise make the new selection the clicked pane and deselect any already selected panes - basically multi-select.

I've searched and tried several different things. I'm thinking the solution will probably involve using Javaobjects and installing an event handler.

I could then monitor the process and keep a state variable of whether the control key is up or down.

I also found the Java documentation page for a Key Event:
https://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyEvent.html

and I noticed there is a method "isControlDown()". This might he promising.

Is it possible to get the state or monitor the state of the Control Key?


Another question having to do with the Java FX Scene Builder. On the right-hand side, in the inspector, in the Code section, they have entries for things such as "On Key Pressed". What are these entries used for? Are they places to enter script commands? Do you put references to subroutines to handle the On Key Pressed event? What would I enter in this field in order to have it invoke a B4J subroutine to handle the On Key Pressed event?

Thanks,
Barry.
 
Top