SelectCase

Andreas Raab andreas.raab at gmx.de
Wed Jan 4 20:16:19 UTC 2006


Chris Muller wrote:
> A key-command handler method.
> 
>   keyPressed caseOf:
>     {[$c]->[self copy].
>     [$x]->[self cut].
>     [$v]->[self paste]}
> 
> What's the best way other than case statement to map
> keyPressed to the desired action?

I don't know if there is any "best" method (I think there are only 
different tradeoffs) but this is what I'm using in Tweak for this very 
purpose:

CTextEditor>>onKeyDown: evt
   "Dispatch a keyboard shortcut"
   | action |
   <on: keyDown>
   action := CPlatform current standardEditingKeys lookupEvent: evt.
   action ifNotNil:[self perform: action].

Cheers,
   - Andreas



More information about the Squeak-dev mailing list