Mouse Over GUI, Help/Question SOLVED

Started by IndieBoy, Tue 17/02/2009 19:41:47

Previous topic - Next topic

IndieBoy

I am trying to run a script when the mouse is over a listbox GUI. So what I tried to do was this:
Code: ags

if (gActions.X<=mouse.x<=gActions.Width && gActions.Y<=mouse.y<=gActions.Height)
    {
      TC=0;
    }
 else
    {
      TC=1;
    }

Which doesn't work.
Why can't I treat GUI.width/GUI.height as an int? I am changing the size of the GUI as I am adding more things to the list box, but this code is in repeatedly_execute so that shouldn't matter. Or do I need to make a seperate gui_x, gui_y ints and keep track of the width and height myself? I know this would be possible and a little annoying to do, but I am a little confused why I can't use GUI.width/GUI.height in the same manner?

Unless I am making a very silly mistake with my script..
Quote from: Calin Elephantsittingonface on Tue 08/02/2011 09:00:55
The only person in favour of the mobs seems to be IndieBoy.. but he's scottish so we dont listen to him anyway.

Trent R

#1
Why not use GUI.GetAtScreenXY?

Modified the code from the manual:
Code: ags

GUI *theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
if (theGui == gAction) {
  TC=0;
}
else {
  TC=1;
}



As for your if-statement, I'm not sure you can use x<y<z. I think you have to break those up with &&.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

IndieBoy

#2
Sorry for the late reply, just I haven't had much of a chance to play around with it.
I forgot to mention that the GUI is called by a right click at the mouse(x,y) so the exact cordinates of the GUI changes all the time. So I'm pretty stuck trying to think of how to make an if statement where the mouse is over the GUI.
At the moment I have two ints, MOUSE_X and MOUSE_Y that are basically the width of the gui + the intial mouse x-cord and the height of the gui + the intial mouse y-cord.
So I have a code like this in repeatly execute:
Code: ags

 if (gActions.X<=mouse.x && mouse.x<=MOUSE_X && gActions.Y<=mouse.y && mouse.y<=MOUSE_Y)
    {
       TC=1    
    } 

But this still doesn't want work. Is there a limit in how many things you can have in an if statement?

:'(
[/s]

All is fine now :D
Quote from: Calin Elephantsittingonface on Tue 08/02/2011 09:00:55
The only person in favour of the mobs seems to be IndieBoy.. but he's scottish so we dont listen to him anyway.

SMF spam blocked by CleanTalk