jmon Well-Known Member Licensed User Longtime User Jan 24, 2014 #1 Hello, I can't figure out how to respond to keyboard events in B4J, a bit like keypressed in B4A. I want my application to respond to {ENTER} or {SHIFT + ENTER} strokes. Thanks [EDIT] Solution in post #6 Last edited: Jan 28, 2014
Hello, I can't figure out how to respond to keyboard events in B4J, a bit like keypressed in B4A. I want my application to respond to {ENTER} or {SHIFT + ENTER} strokes. Thanks [EDIT] Solution in post #6
Erel B4X founder Staff member Licensed User Longtime User Jan 24, 2014 #2 The problem with keyboard events is that most nodes intercept the events and will not let you handle them. Currently the keyboard events are not exposed. However even when they will be exposed you will still not be able to catch these events unless the form is empty. Upvote 0
The problem with keyboard events is that most nodes intercept the events and will not let you handle them. Currently the keyboard events are not exposed. However even when they will be exposed you will still not be able to catch these events unless the form is empty.
jmon Well-Known Member Licensed User Longtime User Jan 24, 2014 #3 Thanks. So, in the case of a chat program, there are now ways to send the message typed in a textArea by pressing "enter"? Upvote 0
Thanks. So, in the case of a chat program, there are now ways to send the message typed in a textArea by pressing "enter"?
Erel B4X founder Staff member Licensed User Longtime User Jan 24, 2014 #4 You can handle the enter button if you use TextField (single line text box). You can then handle the Action event which is raised when the user presses on the enter button. Upvote 0
You can handle the enter button if you use TextField (single line text box). You can then handle the Action event which is raised when the user presses on the enter button.
jmon Well-Known Member Licensed User Longtime User Jan 24, 2014 #5 Thanks, Ok, I will use the textfield for the moment being. I found someone who managed to do what I want in java : https://stackoverflow.com/questions...a-how-to-stop-it-from-consuming-enter-and-tab So if you have time to implement something like this in the next update, that would be awesome. Best, jmon Upvote 0
Thanks, Ok, I will use the textfield for the moment being. I found someone who managed to do what I want in java : https://stackoverflow.com/questions...a-how-to-stop-it-from-consuming-enter-and-tab So if you have time to implement something like this in the next update, that would be awesome. Best, jmon
jmon Well-Known Member Licensed User Longtime User Jan 28, 2014 #6 Hi, I found a solution using the jRELECTION library (you will need to install it to use the following example : http://www.b4x.com/android/forum/threads/jreflection-library.35448/#content), and it works as I needed it. I can now get SHIFT+ENTER or ENTER event in the TextArea control! ;-) So in this example I use a class to create my controls, and in each class instance, I add event handlers that will be local to this class instance. Also the example shows how to do key combination like {SHIFT+ENTER}. It's quite easy to implement. I just have a question regarding this example. I get a "java.lang.NullPointerException / at com.sun.javafx.scene.control.skin.TextAreaSkin.scrollBoundsToVisible(TextAreaSkin.java:998)" error when I scroll the mouse in the TextArea control. Anyone knows why? Regards, Jmon Attachments KeyboardEvent.zip KeyboardEvent.zip 2.5 KB · Views: 1,172 Upvote 0
Hi, I found a solution using the jRELECTION library (you will need to install it to use the following example : http://www.b4x.com/android/forum/threads/jreflection-library.35448/#content), and it works as I needed it. I can now get SHIFT+ENTER or ENTER event in the TextArea control! ;-) So in this example I use a class to create my controls, and in each class instance, I add event handlers that will be local to this class instance. Also the example shows how to do key combination like {SHIFT+ENTER}. It's quite easy to implement. I just have a question regarding this example. I get a "java.lang.NullPointerException / at com.sun.javafx.scene.control.skin.TextAreaSkin.scrollBoundsToVisible(TextAreaSkin.java:998)" error when I scroll the mouse in the TextArea control. Anyone knows why? Regards, Jmon