Cursor hide

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

Cursor hide

Sean M-4
I have a simple view.. It's a dodgy hack and I'm just overriding the
#onMouseMove: and #onMouseLeave: messages.

onMouseMove: aMouseEvent
    Cursor hide.
    ^super onMouseMove: aMouseEvent

onMouseLeave: aMouseEvent
    Cursor show.
    ^super onMouseLeave: aMouseEvent


The hiding of the cursor works, but showing the cursor doesn't work. The
only way to get the cursor back is to restart the image.. Anyone have any
suggestions as to what I'm doing wrong?


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Sean M-4
>I have a simple view.. It's a dodgy hack and I'm just overriding the
>#onMouseMove: and #onMouseLeave: messages.

I think I just worked it out.. Seems that the WinAPI keeps a count of how
many times the cursor has been hidden, and it nees to be unhidden an equal
number of times?

In my implementation, I'm probably hiding the cursor thousands of times (for
each of those mouse events being fired), which means I then need to unhide
it thousands of times. Crap. Some sort of gaurd clause to make sure I only
fire it once or something?


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Esteban A. Maringolo-3
In reply to this post by Sean M-4
Sean,

Sean M escribió:

> I have a simple view.. It's a dodgy hack and I'm just overriding the
> #onMouseMove: and #onMouseLeave: messages.
>
> onMouseMove: aMouseEvent
>     Cursor hide.
>     ^super onMouseMove: aMouseEvent
>
> onMouseLeave: aMouseEvent
>     Cursor show.
>     ^super onMouseLeave: aMouseEvent

The mouse move event is signaled each time the mouse cursors moves
one pixel inside of your view area, so, if it travels 10 pixels,
you'll signal 10 times the event.

What you can do is add an instance variable containing whether the
cursor has been already hidden.

And ensure to show it again when the view is closed/destroyed.

In some command like controls, you have the WM_HOTSPOT message, but
it is only available on WinXP.

> The hiding of the cursor works, but showing the cursor doesn't work. The
> only way to get the cursor back is to restart the image.. Anyone have any
> suggestions as to what I'm doing wrong?

Perhaps you're hidding it too many times. And showing it only once.

Best regards,

--
Esteban.


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Christopher J. Demers
In reply to this post by Sean M-4
"Sean M" <[hidden email]> wrote in message
news:4394297d$0$23309$[hidden email]...

>I have a simple view.. It's a dodgy hack and I'm just overriding the
>#onMouseMove: and #onMouseLeave: messages.
>
> onMouseMove: aMouseEvent
>    Cursor hide.
>    ^super onMouseMove: aMouseEvent
>
> onMouseLeave: aMouseEvent
>    Cursor show.
>    ^super onMouseLeave: aMouseEvent
>
>
> The hiding of the cursor works, but showing the cursor doesn't work. The
> only way to get the cursor back is to restart the image.. Anyone have any
> suggestions as to what I'm doing wrong?

I have a graph presenter and when the cursor is over it I make it a cross.
I override the onGetCursor: method and return a cross cursor, see bellow:
=======
onGetCursor: aSymbol
^Cursor cross.
=======
You might be able to adapt the code like this (untested):
=======
onGetCursor: aSymbol
^Cursor no.
=======

It does not look like I do anything to change the cursor back, it seems to
be automatic when the cursor leaves the presenter's view.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Sean M-4
In reply to this post by Sean M-4
> The hiding of the cursor works, but showing the cursor doesn't work. The
> only way to get the cursor back is to restart the image.. Anyone have any
> suggestions as to what I'm doing wrong?

So I solved showing the cursor. The issue is now that #onMouseLeave: never
fires. Dammit


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Aaron Wieland-3
Sean M wrote:
> So I solved showing the cursor. The issue is now that #onMouseLeave: never
> fires.

You may need to register your presenter/view with a MouseTracker before
the event fires.  I've never tried that before, so I'm not sure, but
that's what I remember learning when I had a similar problem.

Instead, I used SetCursor().  I was dealing with both Dolphin and C++
code, and making the change on the C++ side seemed easier and more
efficient.  I just tried doing the same thing in Dolphin, however, and
it works.  I overrode #wmSetCursor:wParam:lParam: in my view class:

wmSetCursor: message wParam: wParam lParam: lParam
        UserLibrary default setCursor: nil.
        ^true

And that was it.  It doesn't seem to matter whether the method answers
true or false.

Cheers,
-- Aaron


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Blair McGlashan-3
In reply to this post by Sean M-4
"Sean M" <[hidden email]> wrote in message
news:4394b8c8$0$23318$[hidden email]...
>> The hiding of the cursor works, but showing the cursor doesn't work. The
>> only way to get the cursor back is to restart the image.. Anyone have any
>> suggestions as to what I'm doing wrong?
>
> So I solved showing the cursor. The issue is now that #onMouseLeave: never
> fires. Dammit

Unfortunately Windows does not send WM_MOUSELEAVE unless you specifically
issue a request to receive it by calling the TrackMouseEvent() API. In
Dolphin this can be achieved by sending #trackMouseLeave to the View in
question. This is not a sticky request - once a WM_MOUSELEAVE has been sent,
you will have to call it again when the mouse re-enters the window (which
you could do in the mouse move handler). The same applies to WM_MOUSEHOVER,
and indeed you can see an example of the usage of this in the
SlideyInneyOuteyThing.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Christopher J. Demers
In reply to this post by Sean M-4
"Sean M" <[hidden email]> wrote in message
news:4394b8c8$0$23318$[hidden email]...
>> The hiding of the cursor works, but showing the cursor doesn't work. The
>> only way to get the cursor back is to restart the image.. Anyone have any
>> suggestions as to what I'm doing wrong?
>
> So I solved showing the cursor. The issue is now that #onMouseLeave: never
> fires. Dammit

I am wondering if my previous reply did not propagate to your server.  Take
a look at it here
http://groups.google.com/group/comp.lang.smalltalk.dolphin/msg/aed0152af560bc25 .
If you can add this method to the presenter for your view I think you will
see that it does what you need.  If your view does not have a presenter you
can still use this approach as it looks like it send the message to the
interactor, which will default to the view.  So you could just add this
method to the view and it looks like it will work without a presenter.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Aaron Wieland-3
Christopher J. Demers wrote:
> I am wondering if my previous reply did not propagate to your server.  Take
> a look at it here
> http://groups.google.com/group/comp.lang.smalltalk.dolphin/msg/aed0152af560bc25 .

Oops; I had forgotten all about your solution when I suggested one of my
own.  Your idea is definitely more elegant; overriding a public
presenter method is preferable to overriding a private view method
(especially if your presenter doesn't use a custom view class).

 > onGetCursor: aSymbol
 > ^Cursor no.

One minor quibble: When I tried this, the cursor changed to a circle
with a line through it.  To make the cursor disappear, I changed the
method to:

onGetCursor: aSymbol
        ^Cursor new handle: nil; yourself

Also, as indicated by Blair's reply, I was wrong about using
MouseTracker to track the WM_MOUSELEAVE.  I knew about the need to
explicitly and repeatedly request the event, but was mistaken about the
means of doing so.  Oops again.

Cheers,
-- Aaron


Reply | Threaded
Open this post in threaded view
|

Re: Cursor hide

Christopher J. Demers
"Aaron Wieland" <[hidden email]> wrote in message
news:[hidden email]...
> Christopher J. Demers wrote:
...
> > onGetCursor: aSymbol
> > ^Cursor no.
>
> One minor quibble: When I tried this, the cursor changed to a circle with
> a line through it.  To make the cursor disappear, I changed the method to:
>
> onGetCursor: aSymbol
> ^Cursor new handle: nil; yourself
...

Oops! I guess I assumed "no" meant no cursor, not a "don't do that" cursor.
;)  Thanks for flushing that out.

Chris