Mouse over button?

Started by Matti, Sun 11/01/2009 22:33:04

Previous topic - Next topic

Matti

Sorry, perhaps I'm just too tired... but:

I want to check if the mouse is over a certain GUI-Button (cause then a label with a description should appear). I only found solutions for either other locations (hotspots, regions etc.) or for GUI-buttons when a mousebutton is pressed but that's not the case.

I guess GetAtScreenXY could help but I admit that I don't quite understand that command.

So any help is appreciated.

Dualnames

#1
function rep_exec() {
GuiControl*button=GuiControl.GetAtScreenXY(mouse.x,mouse.y);
if (button==Btnnamehere) {
//ecc
}

Note: That GuiControl can be used for all GUI controls.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ryan Timothy B

There is no sense in checking the mouse each and every loop (since it's in the Rep_Exec) if the GUI isn't even visible.

So I'd just put an if statement to check if it was visible, then run the code.
Code: ags

if (gwhatever.Visible==true) {
//check to see if mouse is over button code
}

Matti

Thanks, that works.

The only thing is that the "Gui" in GUIControl has to be written in capital letters in order to be recognized, but I could figure that out myself.  :=

Dualnames

Quote from: matti on Sun 11/01/2009 23:11:59
Thanks, that works.

The only thing is that the "Gui" in GUIControl has to be written in capital letters in order to be recognized, but I could figure that out myself.  :=

I'd kill you if you couldn't. 8)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk