I have a gui that will drop down from the top of the screen and stay visible as long as the right mouse button is being held down. Afterwards, if the right mouse button is released the gui will go back to its default position.
I use this code in the "Player enters room before fade-in" section:
gMenu.SetPosition(0,-20);
In the rep_ex section I use this code:
if (mouse.IsButtonDown(eMouseRight))
gMenu.SetPosition(0,0);
else gMenu.SetPosition(0,-20);
The gui drops down how I want it to however, I can't make any of the buttons work; and yes my gui is clickable. I have tested my button functionality with a generic gui that doesnt move and the buttons work fine. I'm guessing there is some contention with the button functionality when the right mouse button is being held down at the same time you left click on the gui button. I'm sure there is a simple fix to my problem but I havent found it yet. Thanks
Redbeard
At first another thing: move the single line to game_start, or even better, set the GUIs initial position in the GUI editor pane in the editor.
Then use the rep_ex in the global script (unless you need this functionality for one room only), otherwise you'll have to put the code into every room.
(You can still restrict code in the global script to be run in specific rooms only by checking player.Room first.)
Concerning your problem:
I've tested it, appearantly, mouse clicks aren't registered until no mouse button is pressed before the click.
However, you could try to add the following to rep_ex:
if (mouse.IsButtonDown(eMouseLeft) && GUI.GetAtScreenXY(mouse.x, mouse.y)==gMenu) {
Ã, GUIControl*gc=GUIControl.GetAtScreenXY(mouse.x, mouse.y);
Ã, Button*b=gc.AsButton;
Ã, if (b!=null) {
Ã, Ã, if (b==button1) button1_Click(b, eMouseLeft);
Ã, Ã, if (b==button2) button2_Click(b, eMouseLeft);
Ã, Ã, ...
Ã, }
}
You'd have to replace button1, button2, ... with the names of your buttons, of course, and since the _Click functions are in the global script, you need to import them first.
Just add import function [button's name]_Click(GUIControl*control, MouseButton button); to the header for every button.