keyboard event

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

keyboard event

Hans Schueren
Hello again ,


could someone tell me the syntax for a keybord input ?

I want to write a method which ask for keyboard input.

Is this possible.


Hans



Reply | Threaded
Open this post in threaded view
|

Re: keyboard event

Sven Van Caekenberghe-2

> On 27 Oct 2014, at 21:08, Hans Schueren <[hidden email]> wrote:
>
> Hello again ,
>
>
> could someone tell me the syntax for a keybord input ?
>
> I want to write a method which ask for keyboard input.
>
> Is this possible.
>
>
> Hans

The easiest way that is available is like this:

UIManager default request: 'What is your name ?'.

UIManager default confirm: 'Do you like Pharo ?'.

Try inspecting each expression separately.

HTH,

Sven


Reply | Threaded
Open this post in threaded view
|

Re: keyboard event

kilon.alios
In reply to this post by Hans Schueren
yes again if you browse Morphic you will find the event-handling protocol

two methods I tested is handleKeyStroke: that should return true so that your morph handles key strokes events and then you need to also override keyStroke: itself to do whatever you want to do, from there on you can check the KeyboardEvent class to see what the event that is passed to keyStroke: as argument is. for example

keyStroke: event
event inspect.
(event keyCharacter = $h) ifTrue: [ Transcript open. Transcript show: 'Hello User and welcome to Pharo :) ']

the above assume you have created a class that is subclass of Morph and you override the methods mentioned in that class. 



On Mon, Oct 27, 2014 at 10:08 PM, Hans Schueren <[hidden email]> wrote:
Hello again ,


could someone tell me the syntax for a keybord input ?

I want to write a method which ask for keyboard input.

Is this possible.


Hans