Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Hand/click cursor when hover over button

Author
Message
joe90p
13
Years of Service
User Offline
Joined: 29th Jan 2011
Location:
Posted: 29th Jan 2011 11:38
Hi,

I have a sprite which I want to behave as a button (respond to clicks etc). I have created an IsButtonClicked method which determines if the cursor is inside the button and has been clicked



You will notice in the above snippet that I have tried to change the cursor while the cursor is inside the button.

My problem is that each time I move the mouse the cursor changes back to the standard pointer cursor, which according to http://msdn.microsoft.com/en-us/library/ms648380%28v=vs.85%29.aspx#_win32_Displaying_a_Cursor is expected. As a result when I move my mouse inside the buttn/sprite I get a flickering between the pointer cursor and the hand cursor.

The above link suggests handling the WM_SETCURSOR message but this seems impossible in DarkGDK (is it?).

Any suggestions to get round the flickering behaviour?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 29th Jan 2011 12:11 Edited at: 29th Jan 2011 12:19
Quote: "The above link suggests handling the WM_SETCURSOR message but this seems impossible in DarkGDK (is it?)."


i believe it's possible, try this:



haven't tried, but i think it should do it, what's happening there is: we saved the default GDK window procedure in defGDKproc, and we set the new procedure to myProc, so all messages are now sent to myProc, we intercept the messages we want (in this case:WM_SETCURSOR), and call CallWindowProc for the rest, what this does is to call the GDK proc, as if we did not do anything

Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 30th Jan 2011 23:26
A very simple method for this is you could just hide the default cursor and then have 2 images, an Arrow and a Hand. By default have it paste the Arrow image at the mouse x,y. If over the image paste the Hand image at the mouse x,y.


@Hassan: I think that is very interesting that you can basicly "hijack" the windows procedure from GDK, I wasn't aware that could be done and is very good to know.

joe90p
13
Years of Service
User Offline
Joined: 29th Jan 2011
Location:
Posted: 5th Feb 2011 10:17
@Hassan - Thank you. I have successfully managed to handle windows messages using a modified version of your code below.

However, I am still getting the flickering behaviour. When I set the cursor on handling WM_SETCURSOR I got bad flickering. When I set the cursor on WM_SETCURSOR and WM_MOUSEMOVE I got no flickering but dbMouseX() and dbMouseY() stopped working, presumably because the WM_MOUSEMOVE was being trapped.

Most recently, in the code below, when handling WM_MOUSEMOVE I have tried to set the cursor after calling gdkProc. This still produces flickering.

Any ideas?

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 5th Feb 2011 17:28 Edited at: 5th Feb 2011 17:33
not sure, but maybe returning what GDK proc returns might work?


or just return zero:
Quote: " MSDN WM_MOUSEMOVE Message
Return Value

If an application processes this message, it should return zero.
"


Login to post a reply

Server time is: 2024-06-23 03:15:08
Your offset time is: 2024-06-23 03:15:08