Alice Community  

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

Reply
 
Thread Tools Display Modes
AddKeyListener?
Old
mcavner
Junior Member
 
mcavner's Avatar
 
Status: Offline
Posts: 10
Join Date: Sep 2008
Location: Ardmore
Default AddKeyListener? - 10-12-2010, 09:08 PM

I'm using Alice 3 and would like for the arrow keys to move an object. I selected the object and the only method that looks hopeful is AddKeylistener. It sets up a "Declare procedure KEYPRESSED with parameter" and I don't have a clue how to use it. Has anyone used this or can someone provide insight as to how to accomplish?
   
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 10-13-2010, 06:16 AM

Played around with it for a bit and found it. It's definitely not an obvious solution, nor is it really practical, in my opinion, but it is functional. However, you'll need a separate keyListener for each procedure you want done simultaneously, as each keyListener can only handle one key at a time.

Unzip the file below to find my a3p file, then use the arrow keys to move the henchman.
Attached Files
File Type: zip Alice3Keys.zip (27.7 KB, 24 views)
   
Reply With Quote
Old
mcavner
Junior Member
 
mcavner's Avatar
 
Status: Offline
Posts: 10
Join Date: Sep 2008
Location: Ardmore
Default 10-13-2010, 01:37 PM

Thank you - works exactly like I needed!
   
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 10-13-2010, 01:39 PM

You're very welcome.

Glad I could help you this time.
   
Reply With Quote
addMouseButtonListener?
Old
tiesi
Guest
 
Status:
Posts: n/a
Talking addMouseButtonListener? - 12-07-2010, 12:59 PM

Thanks a lot!
But "addMouseButtonListener", which mousebutton left button or right button?
Sorry, my English is very bad, my mother language is chinese!
   
Reply With Quote
mouseKeyListner
Old
deciple44
Guest
 
Status:
Posts: n/a
Default mouseKeyListner - 12-09-2010, 10:23 AM

With the addMouseKeyListner, it would serve the same function as the addKeyListner, meaning if you wanted to assign a method to the left mouse you would have to delcare that in the addMouseListner. Let me know if that helps.
   
Reply With Quote
Reply

Tags
addkeylistener, keypressed

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.