Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Cordate on Sun 09/10/2022 21:17:12

Title: Button not working as it should
Post by: Cordate on Sun 09/10/2022 21:17:12
I made a GUI that has a button to close it, but for some reason the button won't click. I haven't been able to figure out what's going on because I both have clickable set to true as the default and I also have the function for the onclick event set and without typos. As for the code itself I have

function GGOk_OnClick(GUIControl *control, MouseButton button)
{
  GlobeGUI.Visible = false;
  PortraitGUI.Visible = true;
}

With other buttons this has worked for me so I'm really at a loss rn
Title: Re: Button not working as it should
Post by: Khris on Sun 09/10/2022 22:32:34
1. Is the OnClick function linked in the button's events table? You say typos but liking it via the ellipses button auto-generates the entire function signature...

2. Is another (transparent) GUI covering the button?
Title: Re: Button not working as it should
Post by: Cordate on Sun 09/10/2022 23:17:36
Quote from: Khris on Sun 09/10/2022 22:32:341. Is the OnClick function linked in the button's events table? You say typos but liking it via the ellipses button auto-generates the entire function signature...

2. Is another (transparent) GUI covering the button?

I used the ellipses to generate it, which is how I know there are no typos. As far as I'm aware there isn't another GUI blocking it, unless ones with their visibility set to false count
Title: Re: Button not working as it should
Post by: Khris on Sun 09/10/2022 23:31:27
Ok, so try adding something like
  Display("GGOk");in the function to see if it runs or not.

If it doesn't show up, put a label (lblDebug) on a GUI and put something like this in repeatedly_execute_always:

  int gui_id = -1;
  GUI* g = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (g != null) gui_id = g.ID;
  int ctrl_id = -1;
  GUIControl* gc = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  if (gc != null) ctrl_id = gc.ID;
  lblDebug.Text = ("GUI: %d, Control: %d", gui_id, ctrl_id);
Title: Re: Button not working as it should
Post by: Cordate on Mon 10/10/2022 01:46:59
The GUI I'm struggling with or any other?

Title: Re: Button not working as it should
Post by: Cordate on Mon 10/10/2022 02:41:44
not sure if this is an important detail but I just noticed I can still interact with things behind the gui if I click in the right spot
Title: Re: Button not working as it should
Post by: Cordate on Mon 10/10/2022 02:55:07
fixed it. The GUI itself had clickable set to false