How to make a Morph that gets to handle all arrow-key-events?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make a Morph that gets to handle all arrow-key-events?

Helene Bilbo
hi,
for a game i want one Morph to get all the arrow-key-events, whether it has the focus or not.
what is the best way to make this happen?

is it a good idea anyway? One Morph-Object can be moved around the screen using arrow keys. i thought it would be the best if it would listen to the arrow-key-events itself?

thank you very much for help.
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Stéphane Ducasse
Change your alias.
It is childish to ask for help in programming if you do not want to program.
Use any funny alias but not that one!

Stef

>
> hi,
> for a game i want one Morph to get all the arrow-key-events, whether it has
> the focus or not.
> what is the best way to make this happen?
>
> is it a good idea anyway? One Morph-Object can be moved around the screen
> using arrow keys. i thought it would be the best if it would listen to the
> arrow-key-events itself?
>
> thank you very much for help.
> --
> View this message in context: http://forum.world.st/How-to-make-a-Morph-that-gets-to-handle-all-arrow-key-events-tp3052458p3052458.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Helene Bilbo
I dont think beeing reluctant must be a bad thing to learn something. If you are sceptic about something it may often lead to interesting results. And it was for sure not meant as an offence.

But in order to get help i changed the alias.

Stéphane Ducasse wrote
Change your alias.
It is childish to ask for help in programming if you do not want to program.
Use any funny alias but not that one!

Stef
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Stéphane Ducasse
In reply to this post by Stéphane Ducasse
tx helene I prefer to think that I talk to humans :)

Programming is fun in certain language.
Stef

On Nov 22, 2010, at 10:24 AM, Helene Bilbo wrote:

>
> I dont think beeing reluctant must be a bad thing to learn something. If you
> are sceptic about something it may often lead to interesting results. And it
> was for sure not meant as an offence.
>
> But in order to get help i changed the alias.
>
>
> Stéphane Ducasse wrote:
>>
>> Change your alias.
>> It is childish to ask for help in programming if you do not want to
>> program.
>> Use any funny alias but not that one!
>>
>> Stef
>>
> --
> View this message in context: http://forum.world.st/How-to-make-a-Morph-that-gets-to-handle-all-arrow-key-events-tp3052458p3053311.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Lukas Renggli
Have a look at for example SimpleHierarchicalListMorph>>#keyStroke:
and #arrowKey:. It handles arrow keys.

Lukas

On 22 November 2010 08:59, Stéphane Ducasse <[hidden email]> wrote:

> tx helene I prefer to think that I talk to humans :)
>
> Programming is fun in certain language.
> Stef
>
> On Nov 22, 2010, at 10:24 AM, Helene Bilbo wrote:
>
>>
>> I dont think beeing reluctant must be a bad thing to learn something. If you
>> are sceptic about something it may often lead to interesting results. And it
>> was for sure not meant as an offence.
>>
>> But in order to get help i changed the alias.
>>
>>
>> Stéphane Ducasse wrote:
>>>
>>> Change your alias.
>>> It is childish to ask for help in programming if you do not want to
>>> program.
>>> Use any funny alias but not that one!
>>>
>>> Stef
>>>
>> --
>> View this message in context: http://forum.world.st/How-to-make-a-Morph-that-gets-to-handle-all-arrow-key-events-tp3052458p3053311.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Pharo-users mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
>
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Helene Bilbo
Thank you, Lukas. I handle the Keystrokes like in Method 11.17 in the PharoByExample book. That part works fine.
What i can’t figure out is
- how i can make one Morph always have the keyboard focus (in the example it gets the focus, when the mouse enters the morph and looses the focus, when the mouse leaves).
- if i can let one Morph handle the arrow keys, and let keystrokes that are not arrow keys be handled by someone else.

Perhaps that is not a good idea anyway and i should have some kind of playfield handling all keyevents…

Best regards, Helene.
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Benjamin Van Ryseghem (Pharo)

On Nov 22, 2010, at 3:12 PM, Helene Bilbo wrote:

>
> Thank you, Lukas. I handle the Keystrokes like in Method 11.17 in the
> PharoByExample book. That part works fine.
> What i can’t figure out is
> - how i can make one Morph always have the keyboard focus (in the  
> example it
> gets the focus, when the mouse enters the morph and looses the  
> focus, when
> the mouse leaves).

Hi Helene, did you try Morph>>#takeKeyboardFocus ?

> - if i can let one Morph handle the arrow keys, and let keystrokes  
> that are
> not arrow keys be handled by someone else.

Yes you can, I think that when a key is pressed (or release), an event  
is thrown through the system, and each object able to catch it use the  
method handleEvent:


Ben

>
> Perhaps that is not a good idea anyway and i should have some kind of
> playfield handling all keyevents…
>
> Best regards, Helene.
> --
> View this message in context: http://forum.world.st/How-to-make-a-Morph-that-gets-to-handle-all-arrow-key-events-tp3052458p3053662.html
> Sent from the Pharo Smalltalk Users mailing list archive at  
> Nabble.com.
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: How to make a Morph that gets to handle all arrow-key-events?

Helene Bilbo
"Benjamin“ wrote
Hi Helene, did you try Morph>>#takeKeyboardFocus ?
Thank you, Benjamin. #takeKeyboardFocus works fine - but as easy, as i can take the KeyboardFocus, as easy it is taken from my Morph as soon, as some other Morph claims the KeyboardFocus.



„Benjamin“ wrote
Yes you can, I think that when a key is pressed (or release), an event  
is thrown through the system, and each object able to catch it use the  
method handleEvent:
Can i know in which order the objects are asked whether they want to handle an Event? Can i influence this order?

Thank you very much again. I already learned a lot by looking up your and Lukas’ suggestions.
Helene.