I attempted to follow this forum thread to find my answer, but for some reason I am still unable to get my desired result.
I am making a menu that will switch screens based on a click or a keyPressed which in this case happens to be F2. I looked over the class KeyEvent and thought that the code would work but I am not seeing the navigation occur. Is there something obvious that is wrong with the way I have the script?
Also, I know that the code should really read event.VK_F2 for the F2 key but I was attempting to troubleshoot.
I also attempted to place a system.gui.messageBox("test") as a test but still no result.
@lrose I have tried the Client Keystroke Event Script and it does in fact work. The issue I have with it is that you can press the key on any screen and then navigate to the desired page. We really only wanted access to that functionality on one page not anywhere in the client.
I have switched the code around so that it now shows print statements. Does the keyCode ever have to be defined by chance? Also, which area will I see the print statements. In the designer is it under Tools / Console?
The path shouldn't have been the issue since I copied it from the window I wish to move to and the name hasn't been changed.
If I press the Preview in the designer, it actually works and will navigate to the other window. However, once I launch the project through the designer the functionality no longer works. Does it matter that this is a popup?
EDIT: It seems that the functionality is not limited because it is a popup. Is scripting limited to the point it wouldn't work in the windowed launch?
You are struggling because event handlers in java Swing consume events at the innermost focused component where a handler is defined, and only "bubble" outwards when there's no handler there. Any input component that has focus will consume key events that you are trying to handle at an outer layer. The client event key handler hooks into the application at a point before Swing tries to follow its focus rules.
Use the Client keystroke handler event, not a component event.