Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: sloppy on Sat 04/03/2006 14:05:57

Title: Cursor change over GUI button
Post by: sloppy on Sat 04/03/2006 14:05:57
How would I get the cursor to change if it goes over a GUI button?
I tried this:

if (GetLocationType(mouse.x,mouse.y) == buttonname) {
    mouse.Mode = eModePointer;
}

But it says "cannot convert GetLocationType to Button."   I can't seem to get this.
Title: Re: Cursor change over GUI button
Post by: Ashen on Sat 04/03/2006 15:33:27
GetLocationType(mouse.x,mouse.y) (http://www.adventuregamestudio.co.uk/manual/GetLocationType.htm) only returns whether the mouse is  character, hotspot, object or nothing - GUIs are counted as nothing, so obviously you can't get the Control name from that. Instead, use GUIControl.GetAtScreenXY(mouse.x, mouse.y) (http://www.adventuregamestudio.co.uk/manual/GUIControl.GetAtScreenXY.htm). Just substitute it in, the code looks fine otherwise.
Title: Re: Cursor change over GUI button
Post by: monkey0506 on Sat 04/03/2006 15:48:28
Actually Buttons aren't the same as generic GUIControl pointers. ;)

So he would have to do:

GUIControl* controlat = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if ((controlat != null) && (controlat.AsButton == buttonname)) {
  mouse.Mode = eModePointer;
  }


Or the like.
Title: Re: Cursor change over GUI button
Post by: Ashen on Sat 04/03/2006 16:11:41
That's probably better practice, but:

if (GUIControl.GetAtScreenXY(mouse.x,mouse.y) == buttonname) {
    mouse.Mode = eModePointer;
}


works.

If you wanted to do something TO the button (e.g. change it's text or graphic) you might have to do it monkey's way.
Title: Re: Cursor change over GUI button
Post by: monkey0506 on Sat 04/03/2006 16:24:09
Hmm...I didn't realize that GUIControl pointers were comparable to derived types.  Thanks for the clarification (correction).
Title: Re: Cursor change over GUI button
Post by: sloppy on Sat 04/03/2006 20:55:41
Thanks guys.  That works.