Swapping Mouse Cursor Image Instantly...

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
synergy
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2005 17:15
Location: Toronto, Canada

Swapping Mouse Cursor Image Instantly...

Postby synergy » Sun Nov 13, 2005 18:38

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

User avatar
Gaal
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Thu Jul 21, 2005 03:36
Location: Ô Toulouse

Re: Swapping Mouse Cursor Image Instantly...

Postby Gaal » Sun Nov 13, 2005 20:09

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

User avatar
synergy
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2005 17:15
Location: Toronto, Canada

Re: Swapping Mouse Cursor Image Instantly...

Postby synergy » Sun Nov 13, 2005 21:46

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

User avatar
synergy
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2005 17:15
Location: Toronto, Canada

Re: Swapping Mouse Cursor Image Instantly...

Postby synergy » Tue Nov 15, 2005 04:42

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


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 11 guests