SaveCursor when mouse is over a gui

Started by Joseph, Wed 19/05/2010 23:39:04

Previous topic - Next topic

Joseph

Hi dudes,

I just simply want to the save the mouse cursor before it goes over a GUI, so when the mouse is no longer over that GUI, it reverts back to the previous cursor.

Here is what I tried, and failed. I read some threads on problems with the "saveCursorUntilItLeaves" function so Im not sure if its even a good way to do this (I put this code in my repeatedly_execute):

Code: ags

  GUI *theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theGui == gTurtleWax)
  {
    SaveCursorUntilItLeaves();
    mouse.Mode = eModePointer;
  } 



When it goes on the GUI it changes to the pointer, but when it leaves it stays as the pointer.

:o
Spread the love...One.Turtle.At.A.Time.
http://www.youtube.com/watch?v=y0A77rohcyg

amanta4ray

I don't know if there is a better way to do it but I use the following code in the repeatedly_execute part of the global script

if (GUI.GetAtScreenXY(mouse.x, mouse.y)==gIconbar){mouse.Mode=eModeInteract;}

Just replace gIconbar with the name of your gui and replace eModeInteract with the mouse mode that you want to use.  Hope it helps!!

Joseph

hI amanta4ray,

Well unfortunately that doesnt really help since its pretty much what I just wrote, minus the "SaveCursorUntilItLeaves"...I need a way to save the previous cursor before it hits the GUI so when the mouse leaves that GUI, it reverts back to the previous used mouse mode.
Spread the love...One.Turtle.At.A.Time.
http://www.youtube.com/watch?v=y0A77rohcyg

Khris

This should work:

Code: ags
// above rep_ex

int old_mode;
bool has_been_over_gui;

// inside rep_ex

  GUI*g = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (g != gTurtleWax) {  // not over gui
    if (!has_been_over_gui) old_mode = Mouse.Mode;  // continually save current mode
    else {
      Mouse.Mode = old_mode;  // restore mode
      has_been_over_gui = false;
    }
  }
  else has_been_over_gui = true;

Joseph

Hi!

Ok, this works perfectly! Thanks a lot :)
Spread the love...One.Turtle.At.A.Time.
http://www.youtube.com/watch?v=y0A77rohcyg

SMF spam blocked by CleanTalk