keyboard listener

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

keyboard listener

Christian Ponti
hi all,
I want to build a navigation system for a JunOpenGLDisplayModel, which
is a subclass of ApplicationModel. The navigation system should listen
for arrow keys and change zooming, eye view, camera and so on.
The following is the code, got from Smalltalk by Example:

postBuildWith: aBuilder
        |controller|
        super postBuildWith: aBuilder.
        controller := (self builder componentAt: #cipLB) widget controller.
        controller keyboardHook: self myKeyboardHookBlock.


myKeyboardHookBlock
        ^
        [:event :controller|
        |selector|
        selector := keyboardSelectors at: event keyValue ifAbsent: [nil].
        selector notNil ifTrue: [self perform: selector].
        event]

mySetUpKeyboardSelectors

        keyboardSelectors := Dictionary new.
        keyboardSelectors
                at: #Right put: #zooming

I think that the key is in postBuildWith:, where the code gives me
errors (usually message not understood widget), and if I understand well
is the listener.
In addition I need only a key handler, not something related to a menu,
and I cannot find useful documentation around.
Any suggestion?

Christian

Reply | Threaded
Open this post in threaded view
|

Re: keyboard listener

Christian Ponti
Hi all,
found a solution, sending keyboardProcessor to the builder :)

postBuildWith: aBuilder
        |controller|
        super postBuildWith: aBuilder.
        controller := self builder keyboardProcessor.
        controller keyboardHook: self myKeyboardHookBlock.


Christian


On Sat, 2007-05-12 at 19:44 +0200, Christian Ponti wrote:

> hi all,
> I want to build a navigation system for a JunOpenGLDisplayModel, which
> is a subclass of ApplicationModel. The navigation system should listen
> for arrow keys and change zooming, eye view, camera and so on.
> The following is the code, got from Smalltalk by Example:
>
> postBuildWith: aBuilder
> |controller|
> super postBuildWith: aBuilder.
> controller := (self builder componentAt: #cipLB) widget controller.
> controller keyboardHook: self myKeyboardHookBlock.
>
>
> myKeyboardHookBlock
> ^
> [:event :controller|
> |selector|
> selector := keyboardSelectors at: event keyValue ifAbsent: [nil].
> selector notNil ifTrue: [self perform: selector].
> event]
>
> mySetUpKeyboardSelectors
>
> keyboardSelectors := Dictionary new.
> keyboardSelectors
> at: #Right put: #zooming
>
> I think that the key is in postBuildWith:, where the code gives me
> errors (usually message not understood widget), and if I understand well
> is the listener.
> In addition I need only a key handler, not something related to a menu,
> and I cannot find useful documentation around.
> Any suggestion?
>
> Christian
>