Cursor change over GUI button

Started by sloppy, Sat 04/03/2006 14:05:57

Previous topic - Next topic

sloppy

How would I get the cursor to change if it goes over a GUI button?
I tried this:
Code: ags

 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.

Ashen

GetLocationType(mouse.x,mouse.y) 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). Just substitute it in, the code looks fine otherwise.
I know what you're thinking ... Don't think that.

monkey0506

Actually Buttons aren't the same as generic GUIControl pointers. ;)

So he would have to do:

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


Or the like.

Ashen

That's probably better practice, but:
Code: ags

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.
I know what you're thinking ... Don't think that.

monkey0506

Hmm...I didn't realize that GUIControl pointers were comparable to derived types.  Thanks for the clarification (correction).

sloppy


SMF spam blocked by CleanTalk