Keyboard and mouse events in custom view / controller

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

Keyboard and mouse events in custom view / controller

Vincent Lesbros-2
Hi list,

I use VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012
I have to use a custom view and be able to react to mouse and keybord events.
I join a sample application to show precisely my problems.

Thanks for help.
all remarks are welcome.


Vincent



1/ The controller does not receive #processKeyboardEvent: event

- The controller recive #anyfocusKeypressEvent: aKeyPressEvent
but not #processKeyboardEvent:, why ?

2/ when the view receive #invalidate the view is cleared in white
before the #displayOn:
is rececived. How can I avoid this blink ?

3/ redButtonPressedEvent: is received even if a doubleClickEvent: is done.
In the redButtonPressedEvent:  I can decide if this is a double click or not.

4/ can checkboxes be read only ?

5/ How can I manage to map menu short keys to actions ?

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

VL Tests.st (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard and mouse events in custom view / controller

BREITH Karl-Albert (AREVA)


Betreff: [vwnc] Keyboard and mouse events in custom view / controller

Hi list,

I use VisualWorks® Personal Use Edition, 7.9.1 of 18 octobre 2012 I have to use a custom view and be able to react to mouse and keybord events.
I join a sample application to show precisely my problems.

Thanks for help.
all remarks are welcome.


Vincent



1/ The controller does not receive #processKeyboardEvent: event

- The controller recive #anyfocusKeypressEvent: aKeyPressEvent but not #processKeyboardEvent:, why ?

Change like this one:
graphicView

        | view |
        view := MouseKbdView new model: domaineModele.
        view controller keyboardProcessor: builder keyboardProcessor.
        ^view

2/ when the view receive #invalidate the view is cleared in white before the #displayOn:
is rececived. How can I avoid this blink ?

I am on Linux and do not observe this problem.

3/ redButtonPressedEvent: is received even if a doubleClickEvent: is done.
In the redButtonPressedEvent:  I can decide if this is a double click or not.

This is normal. The first click is a red-button click, the second click decides about the double click (or not).
If you don't want that, you have to write your own double-click decision.

I have done this for one application, you don't really want to do so. You'll need your own time-out for single/double click decision etc.
It might be easier to undo the last action in case of double click.

4/ can checkboxes be read only ?

As far as I know: No. But you can avoid the change of value when clicking by your own code.

5/ How can I manage to map menu short keys to actions ?

You mean something like Alt-D for a menu item ?

For menues it's easy: Just have a menu-item like '&Clear'. The Ampersand defines the c as short cut for clear.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard and mouse events in custom view / controller

Vincent Lesbros-2
Thanks Karl-Albert,

> 1/ The controller does not receive #processKeyboardEvent: event
>
> - The controller recive #anyfocusKeypressEvent: aKeyPressEvent but not
> #processKeyboardEvent:, why ?
>
> Change like this one:
> graphicView
>
>         | view |
>         view := MouseKbdView new model: domaineModele.
>         view controller keyboardProcessor: builder keyboardProcessor.
>         ^view

I try it, but I still not receive the message processKeyboardEvent: in
the controller.

>
> 2/ when the view receive #invalidate the view is cleared in white before the
> #displayOn:
> is rececived. How can I avoid this blink ?
>
> I am on Linux and do not observe this problem.

There is an other problem, "sometimes" (I can't reproduce it
sytematically) when I expand the window on the whole screen
by double clicking on the window bar, the scroll bars of the
scrollwrapper are displayed in the middle of the window.

Subsidiary question : when a Window is collapsed (in the task bar of
Windows) and I send a #raise message
the window do not raise.


> 3/ redButtonPressedEvent: is received even if a doubleClickEvent: is done.
> In the redButtonPressedEvent:  I can decide if this is a double click or
> not.
>
> This is normal. The first click is a red-button click, the second click
> decides about the double click (or not).
> If you don't want that, you have to write your own double-click decision.
>
> I have done this for one application, you don't really want to do so. You'll
> need your own time-out for single/double click decision etc.
> It might be easier to undo the last action in case of double click.

OK, I understand.
Anyway, the double-click should be reserved to an action that
completes he click action.

> 4/ can checkboxes be read only ?
>
> As far as I know: No. But you can avoid the change of value when clicking by
> your own code.
>
Poor checkboxes, In a future life, I don't want to be reincarnated
into a checkbox.

> 5/ How can I manage to map menu short keys to actions ?
>
> You mean something like Alt-D for a menu item ?
>
> For menues it's easy: Just have a menu-item like '&Clear'. The Ampersand
> defines the c as short cut for clear.

Yes, but this implies that : a) the menu is open,
b) The label of the menu includes the good letter.

It was not exactly my question.
I am the controller, and the menu is not open.
I receive a #anyfocusKeypressEvent: I can find the menu,
And, in the menu editor I specified a "Shortcut Charracter"
how can I link the receved event to the good item menu action ?
I mean, it shoud be a standar way to do that... ?


Vincent.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Keyboard and mouse events in custom view / controller

BREITH Karl-Albert (AREVA)
 
Your application could do soemthing like:

        aBuilder window keyboardProcessor
                keyboardHook: [:kbEvent :c | self processKeyboardEvent: kbEvent].

The processKeyboardEvent method:
Here you implement all shortvuts you want, for all unknown characters or buttons you return the keyborad event for
interpretation by others.

processKeyboardEvent: aKBEvent
        | key |
        key := aKBEvent keyValue.
        ^key == #PageDown
                ifTrue:
                        [self solutionDown.
                        nil]
                ifFalse: [key == #PageUp
                                ifTrue:
                                        [self solutionUp.
                                        nil]
                                ifFalse: [aKBEvent]]

Raising windows:
This is an issue on windows. I have played around with that, too, but I do not have a really reliable solutions.
On Linux I had changed the raise method to the following (renamed raise to primRaise first):
raise
        "queryStackOrder returns the handles for the windows from bottom to top.
        So the last entry is the topmost window. Because there might be more than one window completely
        visible, the overlapping has to be checked."
        "The window's raise method doesn't work correctly if you are logged in via Linux directly (KDE).
        It works fine if logged in via HP or Windows.
        The 'lower' method works fine"

        | list index |
        self primRaise.
        list := Screen default queryStackingOrder.
        list isNil ifTrue: [^false].
        list := list collect: [:aHandle | DisplaySurface findRegistrant: aHandle].
        self == list last ifTrue: [^true].
        index := list indexOf: self.
        list size to: 1
                by: -1
                do: [:indx | (list at: indx) notNil ifTrue: [indx ~= index ifTrue: [(list at: indx) lower]]].
        ^true



__________________________________________________________
Karl Breith
AREVA GmbH
FDN-G

Postfach 1109
91001 Erlangen
Phone: +49 (0) 9131 900 95544
Fax: +49 (0) 9131 900 94081
mail to:  [hidden email]  
Vorsitzender des Aufsichtsrats: Philippe Knoche - Geschäftsführer: Stefan vom Scheidt, Carsten Haferkamp
Sitz der Gesellschaft: Erlangen - Registergericht: Fürth, HRB 7817 - www.areva-np.com - Umsatzsteuer-ID: DE 206407096  
Supervisory Board Chairman: Philippe Knoche - Managing Directors: Stefan vom Scheidt, Carsten Haferkamp
Company Seat: Erlangen - Commercial Registries Fürth, HRB 7817 - www.areva-np.com - VAT ID code: DE 206407096
Wichtiger Hinweis: Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse bzw. sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.
Important Note: This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal. Thank you for your cooperation.

-----Ursprüngliche Nachricht-----
Von: Vincent Lesbros [mailto:[hidden email]]
Gesendet: Montag, 18. März 2013 13:25
An: BREITH Karl-Albert (FE/FL)
Cc: [hidden email]
Betreff: Re: [vwnc] Keyboard and mouse events in custom view / controller

Thanks Karl-Albert,

> 1/ The controller does not receive #processKeyboardEvent: event
>
> - The controller recive #anyfocusKeypressEvent: aKeyPressEvent but not
> #processKeyboardEvent:, why ?
>
> Change like this one:
> graphicView
>
>         | view |
>         view := MouseKbdView new model: domaineModele.
>         view controller keyboardProcessor: builder keyboardProcessor.
>         ^view

I try it, but I still not receive the message processKeyboardEvent: in the controller.

>
> 2/ when the view receive #invalidate the view is cleared in white
> before the
> #displayOn:
> is rececived. How can I avoid this blink ?
>
> I am on Linux and do not observe this problem.

There is an other problem, "sometimes" (I can't reproduce it
sytematically) when I expand the window on the whole screen by double clicking on the window bar, the scroll bars of the scrollwrapper are displayed in the middle of the window.

Subsidiary question : when a Window is collapsed (in the task bar of
Windows) and I send a #raise message
the window do not raise.


> 3/ redButtonPressedEvent: is received even if a doubleClickEvent: is done.
> In the redButtonPressedEvent:  I can decide if this is a double click
> or not.
>
> This is normal. The first click is a red-button click, the second
> click decides about the double click (or not).
> If you don't want that, you have to write your own double-click decision.
>
> I have done this for one application, you don't really want to do so.
> You'll need your own time-out for single/double click decision etc.
> It might be easier to undo the last action in case of double click.

OK, I understand.
Anyway, the double-click should be reserved to an action that completes he click action.

> 4/ can checkboxes be read only ?
>
> As far as I know: No. But you can avoid the change of value when
> clicking by your own code.
>
Poor checkboxes, In a future life, I don't want to be reincarnated into a checkbox.

> 5/ How can I manage to map menu short keys to actions ?
>
> You mean something like Alt-D for a menu item ?
>
> For menues it's easy: Just have a menu-item like '&Clear'. The
> Ampersand defines the c as short cut for clear.

Yes, but this implies that : a) the menu is open,
b) The label of the menu includes the good letter.

It was not exactly my question.
I am the controller, and the menu is not open.
I receive a #anyfocusKeypressEvent: I can find the menu, And, in the menu editor I specified a "Shortcut Charracter"
how can I link the receved event to the good item menu action ?
I mean, it shoud be a standar way to do that... ?


Vincent.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc