Catching Keyboard events

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

Catching Keyboard events

Barry Carr-2
Hi All,

How do you catch keyboard events going to a specific control on a form?
What I want to do is catch the Insert key when a listview has the current
focus. I've had a scout round but nothing seems obvious. I've tried "wiring  
up" the #keyTyped event but nothing happens. The only other clue I've got
is to either su-class the ListView view or presenter, but this seems like
overkill. Any clues would be appreciated.

Cheers

Barry Carr
Blairgowrie
Perthshire


Reply | Threaded
Open this post in threaded view
|

Re: Catching Keyboard events

Chris Hayes-3
"Barry Carr .arrakis.clara.net>" <barry@<nospam> wrote in message
news:Xns920BA158A18F0barryarrakisclaranet@158.152.254.72...
> Hi All,
>
> How do you catch keyboard events going to a specific control on a form?
> What I want to do is catch the Insert key when a listview has the current
> focus. I've had a scout round but nothing seems obvious. I've tried
"wiring
> up" the #keyTyped event but nothing happens. The only other clue I've got
> is to either su-class the ListView view or presenter, but this seems like
> overkill. Any clues would be appreciated.

Try catching the #keyPressed: event (instead of #keyTyped).  Something like
the following:

    listViewPresenter
        when: #keyPressed:
        send: onKeyPressedInList:
        to: self.


Reply | Threaded
Open this post in threaded view
|

Re: Catching Keyboard events

Barry Carr-2
"Chris Hayes" <hayes@*zapthis*.creative-computing-inc.com> wrote in
news:CffD8.16795$[hidden email]:

> "Barry Carr .arrakis.clara.net>" <barry@<nospam> wrote in message
> news:Xns920BA158A18F0barryarrakisclaranet@158.152.254.72...
>> Hi All,
>>
>> How do you catch keyboard events going to a specific control on a
>> form? What I want to do is catch the Insert key when a listview has
>> the current focus. I've had a scout round but nothing seems obvious.
>> I've tried
> "wiring
>> up" the #keyTyped event but nothing happens. The only other clue I've
>> got is to either su-class the ListView view or presenter, but this
>> seems like overkill. Any clues would be appreciated.
>
> Try catching the #keyPressed: event (instead of #keyTyped).  Something
> like the following:
>
>     listViewPresenter
>         when: #keyPressed:
>         send: onKeyPressedInList:
>         to: self.
>
>

Hi Chris,

Thanks for the suggestion, but it dosen't work. Nothing happens. I even
placed a self halt in the event handling method and it doesn't even get
there. I think this was one of the things I tried before I posted my
original message as this is how I would of expected it work too.

Regards

Barry


Reply | Threaded
Open this post in threaded view
|

Re: Catching Keyboard events

Andy Bower
Barry,

> > Try catching the #keyPressed: event (instead of #keyTyped).  Something
> > like the following:
> >
> >     listViewPresenter
> >         when: #keyPressed:
> >         send: onKeyPressedInList:
> >         to: self.

> Thanks for the suggestion, but it dosen't work. Nothing happens. I even
> placed a self halt in the event handling method and it doesn't even get
> there. I think this was one of the things I tried before I posted my
> original message as this is how I would of expected it work too.

Are you sure you've typed the #keyPressed: event name correctly (including
the colon at the end). Try this:

lp := ListPresenter show.
lp when: #keyPressed: send: #beep to: Sound.

Set focus to the list presenter and hit the Insert key. You should hear a
beep.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com
---
Are you trying too hard?
http://www.object-arts.com/Relax.htm
---


Reply | Threaded
Open this post in threaded view
|

Re: Catching Keyboard events

Barry Carr-2
Cheers Andy!

The colon on the end of #keyPressed: was the missing ingredient!

Regards

Barry