right click ON gui

Started by Sam., Mon 28/03/2005 21:53:57

Previous topic - Next topic

Sam.

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.
Bye bye thankyou I love you.

Ashen

Have you tried on_event, and GUI_MUP/DOWN? E.g.
Code: ags

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.
I know what you're thinking ... Don't think that.

Sam.

heh, it is, my main prblem, can i use the "return;" function to cancel these operations?
Bye bye thankyou I love you.

Ashen

Oh, sure, if you want to do it the easy way.... ;)

Code: ags

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.
I know what you're thinking ... Don't think that.

Sam.

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)
Bye bye thankyou I love you.

Ashen

#5
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?
I know what you're thinking ... Don't think that.

Sam.

oh, okay, i didn't get that bit. cool. thanks very much, ill try that
Bye bye thankyou I love you.

SMF spam blocked by CleanTalk