Hi!
I'd like to change my cursor graphic when hovering over any clickable button.
I am able to change the cursor graphic when hovering over any GUI control, using this code (in the 'repeatedly_execute' section of my global script):
GUIControl *anyGUIControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (anyGUIControl)
{
mouse.ChangeModeGraphic(eModePointer, 2);
}
else
{
mouse.ChangeModeGraphic(eModePointer, 1);
}
However, this also changes the cursor graphic when hovering over GUI labels and unclickable buttons, which I don't want.
Thanks in advance!
if (anyGUIControl && anyGUIControl.AsButton)
Thanks, Khris. Unfortunately, that gives me the following error (line 21 is the line in question):
Error (line 21): Operator cannot be applied to this type
Yeah, I was afraid of that. This should definitely work:
if (anyGUIControl != null && anyGUIControl.AsButton != null)
That worked :) Thanks again, Khris!
For anyone who may stumble across this thread later, and who's wondering about how to stop the cursor from changing graphic when hovering over non-clickable buttons, here's the full code I ended up using.
function repeatedly_execute()
{
GUIControl *anyGUIControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (anyGUIControl != null && anyGUIControl.AsButton != null && anyGUIControl.AsButton.Clickable)
{
mouse.ChangeModeGraphic(eModePointer, 2);
}
else
{
mouse.ChangeModeGraphic(eModePointer, 1);
}
}