B4J Question How to catch shortcut keys within a TextField.

amykonio

Active Member
Licensed User
Longtime User
Hi to everybody.

I've seen an older answer to a post from Daestrum (https://www.b4x.com/android/forum/t...oblem-with-function-keys-and-textfield.63444/).

I'm trying to make some function keys work when the user is writing in a TextField.

Follows a part of Daestrum's code.

B4X:
                if (keyEvent.getEventType() == KeyEvent.KEY_PRESSED){
                    if (keyEvent.getCode() == KeyCode.F12) {
                        try{
                            _mnusampleentry1_action(); // calls your function here for F12
                        }catch (Exception ure){
                            System.out.println("Broke it");
                        }
                    event.consume();
                    }
                    if (keyEvent.getCode() == KeyCode.S && keyEvent.isControlDown()){
                        try{
                            _mnusampleentry2_action(); // calls your function here for ctrl S
                        }catch (Exception ure){
                            System.out.println("Broke it");
                        }
                    event.consume();
                    }
                }

I'm not sure I understand how the above will work.

B4X:
if (keyEvent.getCode() == KeyCode.F12) {
try{
_mnusampleentry1_action(); // calls your function here for F12
}catch (Exception ure){
System.out.println("Broke it");
}
}
The third line in the above section calls a sub written in B4J, or _mnusampleentry1_action() must be a function in pure java?
Does java inline code can call subs written directly in B4X?

Thanks Andreas.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…