Using Key Pressed Listener in 3.1 -
11-30-2012, 11:54 AM
Greetings,
I'm trying to handle a key pressed event in Alice 3.1, but I can't get it to work. I've attached an image that shows the method I'm calling (moveForward), the fact that main (I renamed myFirstMethod) is calling the method to initialize the event handlers, and my initializeEventHandlers method. Clicking the mouse on the screen moves the lioness forward, so the mouse click on screen listener is working as expected. Pressing keys doesn't have any effect, though, so the key press listener isn't working for me.
Thanks, that video did help. The problem was that I assumed the running window automatically had focus when it opened, which the video indicates isn't true. Clicking in the window to listen for the mouse event worked because clicking in the window also gives it focus. Running and just pressing keys didn't work because the window doesn't have focus. If I click in the window to give it focus and then use the keys, everything seems to work fine.