Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Sam. on Mon 28/03/2005 21:53:57

Title: right click ON gui
Post by: Sam. on Mon 28/03/2005 21:53:57
is it possible to call a special set of actions on a RIGHT clcik on a gui? I have tried several ways (isbuttondown, on_mouse_click(right)) and i can't get it oging. is it possible? I basically want my gui to go off if i right click n it but also if i right click on a button.
Title: Re: right click ON gui
Post by: Ashen on Mon 28/03/2005 22:33:24
Have you tried on_event, and GUI_MUP/DOWN? E.g.

int press;


function on_event (int event, int data) {
  if (event == GUI_MDOWN) { // Mouse button pressed
    if (IsButtonDown (RIGHT)) press = 1;
  }
  if (event == GUI_MUP) { // Mouse button released
    if (press == 1) GUIOff (data); // If it was RIGHT, turn of the GUI.
    press = 0;
  }
}


However, if you right click on a GUI button, it runs the button script before closing the GUI, don't know if that's a problem.
Title: Re: right click ON gui
Post by: Sam. on Tue 29/03/2005 11:37:47
heh, it is, my main prblem, can i use the "return;" function to cancel these operations?
Title: Re: right click ON gui
Post by: Ashen on Tue 29/03/2005 15:03:28
Oh, sure, if you want to do it the easy way.... ;)


function on_event (int event, int data) {
  if (event == GUI_MDOWN) { // Mouse button pressed
    if (IsButtonDown (RIGHT)) {
    GUIOff (data);
    return;
    }
  }
}

Does seem to work, yes.
Title: Re: right click ON gui
Post by: Sam. on Tue 29/03/2005 16:06:45
where do I put that? and what changes do i need to make to it? (ie. which bit needs to relate specifically to my code)
Title: Re: right click ON gui
Post by: Ashen on Tue 29/03/2005 16:11:21
on_event can go pretty much anywhere in the global script, but if you want to play safe, put it somewhere before interface_click. (Unless you've already got on_click somewhere, of course.)
And, uh, I don't understand. What code have you got that would make it need changing? With on_event, when event is GUIMDOWN (or GUI_MUP, I think), data is the gui the mouse is over, so the code as-is will close whatever GUI the right button is clicked on. What else do you need?
Title: Re: right click ON gui
Post by: Sam. on Tue 29/03/2005 16:24:13
oh, okay, i didn't get that bit. cool. thanks very much, ill try that