Page 1 of 1

Swapping Mouse Cursor Image Instantly...

Posted: Sun Nov 13, 2005 18:38
by synergy
Hello again everyone,

I am implementing a simple inventory-type GUI function. The usual: click on an item in an inventory slot, swap the mouse cursor to the image of that item, and place the item back in another slot when it is clicked on.

Everything is working as planned except for the mouse cursor swap. Granted, I'm probably not doing the most logical thing, but I've tried a couple things thus far and I've had no luck.

I call this method when a slot is clicked on. However, the mouse cursor only ACTUALLY changes when the mouse is moved fully out of the slot window (which is just a skinned StaticImage box).

Code: Select all

System::getSingleton().setDefaultMouseCursor((static_cast<StaticImage*>(this->selectedItem))->getImage());


Basically, Mr. CrazyEddie and friends, I'd like to know a way to force an instant swap of the mouse cursor when the item is clicked on. Any thoughts?

Thank you,

Ryan

Re: Swapping Mouse Cursor Image Instantly...

Posted: Sun Nov 13, 2005 20:09
by Gaal
Hi,

You can't set the mouse cursor of a window with the setDefaultMouseCursor. This is as the name says THE DEFAULT mouse cursor.

Instead, did you try window->setMouseCursor(imageCursor) ?
where window is your StaticImage .

Gaal

Re: Swapping Mouse Cursor Image Instantly...

Posted: Sun Nov 13, 2005 21:46
by synergy
Hey Gaal,

setDefaultMouseCursor does in fact work in changing the mouse cursor for "a window" since it actually changes the mouse cursor for ALL windows. However, this is not my precise problem.

Even if I call setMouseCursor on the specific window (inventory slot) that the cursor is in when the click is made, the mouse cursor image does NOT change until you move the cursor out of the window completely and then back into it.

I've even tried signalRedraw with hopes that the GUI system needed to be explicitly told to draw everything again, but it appears that the system doesn't actually "reset" the mouse cursor until the MouseEnters event is fired. Can this be overridden?

Thanks for the reply.

Ryan

Re: Swapping Mouse Cursor Image Instantly...

Posted: Tue Nov 15, 2005 04:42
by synergy
Hello again,

I just wanted to give everyone an update on this problem. I solved it using the following approach:

Code: Select all

MouseCursor::getSingleton().setImage(newImage);
System::getSingleton().setDefaultMouseCursor(newImage);


Calling setImage on the MouseCursor singleton provided an instant swap of the mouse cursor in the current window and setDefaultMouseCursor made sure the image didn't swap back to the old default cursor upon moving the mouse out of the current window.

CrazyEddie and Team, I'm not entirely sure if this is the way you intended an instant cursor image swap to be accomplished. I'm interested in hearing any other methods :).

Take care,

Ryan