Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Using Key Pressed Listener in 3.1
Old
chamillard
Junior Member
 
Status: Offline
Posts: 2
Join Date: Nov 2012
Default 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.

Any suggestions would be great.

Thanks,
Dr. T
Attached Images
File Type: jpg event handler problem.jpg (15.2 KB, 17 views)
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-30-2012, 12:40 PM

I just gave this link to a tutorial on events in Alice 3 to someone with a similar problem. Maybe you'll find it useful.

http://www.youtube.com/watch?v=QEzgnRiHTXo&feature=plcp


(')>
   
Reply With Quote
Old
chamillard
Junior Member
 
Status: Offline
Posts: 2
Join Date: Nov 2012
Default 11-30-2012, 01:47 PM

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.

Thanks for your prompt and useful help,
Dr. T
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.