GUI.GetAtScreenXY

Started by Slasher, Wed 27/11/2013 07:32:52

Previous topic - Next topic

Slasher

Hi,

I am trying to incorporate an action for 2 Gui's for the cursor to show arrow and then return mode when off the Gui's.

This script works as it should:

Code: ags

// WHEN CURSOR OVER STATUSLINE GUI
 
  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theGui == gStatusline  && mouse.Mode != eModePointer) 
 {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
  }
if (theGui != gStatusline && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061) 
 {
    mouse.Mode=old_mode;



Now, I also have another Gui (130 x 240 in middle of Room) that shows in a Room along with gStatusline which is named gPasswordGUI.

What I have been trying to do is to incorporate it so that its actions are as per gStatusline: that is the cursor changes to pointer whilst over gPasswordGUI and returns mode when off.

Would you please assist me.

cheers





Gilbert

(Not tested) Wouldn't the codes below work? (Parentheses added for clarity)

Code: ags

// WHEN CURSOR OVER STATUSLINE GUI
 
  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if ((theGui == gStatusline||theGui ==  gStatusline) && mouse.Mode != eModePointer) 
 {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
  }
if ((theGui != gStatusline&heGui ==  gStatusline) && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061) 
 {
    mouse.Mode=old_mode;



if you find that too many logical comparison in the same if-clause confusing you can break them down at those && part for easier reading.

Slasher

Hi Iceboty V7000a,

I've got the script to work using the below script. I don't know if it is the 'coder's' way but it does work.
Code: ags

 // WHEN CURSOR OVER STATUSLINE OR PASSWORD GUI

  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theGui == gStatusline  && mouse.Mode != eModePointer)
  {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
    } 
  if (theGui == gPasswordGUI && mouse.Mode != eModePointer)
  {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
    }
  if (theGui != gStatusline && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061) 
  if (theGui != gPasswordGUI && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061)
  {
    mouse.Mode=old_mode;


So, although this is solved I am open to other ways to adopt.

cheers




Khris

This is what I would do:
Code: ags
// above rep_exe
GUI *prevGui;

// inside
  
  GUI *theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  
  if ((theGui == gStatusline || theGui == gPasswordGUI) && prevGui == null) {
    old_mode = mouse.Mode;
    mouse.ChangeModeGraphic(eModePointer, 2061);
    mouse.Mode = eModePointer;
  }

  if ((prevGui == gStatusline || prevGui == gPasswordGUI) && theGui == null) {
    mouse.Mode = old_mode;
  }

  prevGui = theGui;

Slasher

Cheers Khris,

I will adopt (nod)

cheers

slasher

SMF spam blocked by CleanTalk