ListPresenter and keyPressed...

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

ListPresenter and keyPressed...

talios@gmail.com
Something simple I'm sure, I have a view with an enhanced listbox in
report view, I have the following hooking up a keypress beep:

    allContacts when: #keyPressed: send: #beep to: Sound.

I hear a beep for every key press EXCEPT for the enter-key ( which is
actually the only key I'm interested in in the first place ).

Running the following from a workspace:

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

I hear the beep on the enter-key as one would expect.

Any ideas?


Reply | Threaded
Open this post in threaded view
|

Re: ListPresenter and keyPressed...

Ian Bartholomew-19
Mark,

> I hear a beep for every key press EXCEPT for the enter-key ( which is
> actually the only key I'm interested in in the first place ).

It seemed to work OK when I tried it in an EnhancedListView.  I got a beep
for every key I tried, including the enter key.

If you want to be notified when the enter key is pressed with a selection
made in the list then have a look at the #actionPerformed trigger.  It fires
when a list item is double-clicked or the enter key is pressed.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: ListPresenter and keyPressed...

Chris Uppal-3
In reply to this post by talios@gmail.com
Mark Derricutt wrote:

> I hear a beep for every key press EXCEPT for the enter-key ( which is
> actually the only key I'm interested in in the first place ).

The <enter> key is considered to be invoking the list's "action" (all Views
have an action) which can also be invoked by double-clicking. The default
"action" in a list is to do nothing, you can set an action with code like:

    list when: #actionPerformed send: #whatever to: self.

or by overriding the appropriate methods in the Presenter attached to the list.

One word of warning: I don't think the action is invoked unless the list has a
current selection (which is  probably how you want it to behave, but just in
case...).

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: ListPresenter and keyPressed...

talios@gmail.com
In reply to this post by Ian Bartholomew-19
Ian Bartholomew wrote:

>It seemed to work OK when I tried it in an EnhancedListView.  I got a beep
>for every key I tried, including the enter key.
>
>  
>
Thats odd - not seeing that here.  Will have to make up a test form and
try it...

>If you want to be notified when the enter key is pressed with a selection
>made in the list then have a look at the #actionPerformed trigger.  It fires
>when a list item is double-clicked or the enter key is pressed.
>  
>
I had suspected this, but I'm already responding to #actionPerformed.  
Mmmmm.


Reply | Threaded
Open this post in threaded view
|

Re: ListPresenter and keyPressed...

Schwab,Wilhelm K
Mark,

> Ian Bartholomew wrote:
>
>> It seemed to work OK when I tried it in an EnhancedListView.  I got a
>> beep
>> for every key I tried, including the enter key.
>>
> Thats odd - not seeing that here.  Will have to make up a test form and
> try it...

Are you certain the view is properly connected to the presenter?  I
sometimes get weird results if I forget to set the name of a subview.  I
_think_ you have implied all is well in that regard, but I'll mention it
JIC.

As you are probably aware, another common reason things don't work is to
register interest in a bogus selector.  Did you perhaps ask for
#keyPressed vs. #keyPressed: in your "real" presenter?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]