GUI Issues

Started by Sickened, Thu 14/07/2011 15:53:35

Previous topic - Next topic

Sickened

I have a GUI bar that sits at the bottom of the screen the whole game, and when you press a button on the bar, another GUI pops up enabling you to do whatever that particular GUI does.. but the clicks aren't registering when I click on the buttons in-game. I've added an invisible "button" over everything on the bar, and like I said, it's not registering. I've attached the bar GUI because I know I probably didn't explain that well XD



Uploaded with ImageShack.us

monkey0506

#1
Some items you may want to check:

- Are the "OnClick" event handlers linked to the Buttons? Check this in the editor, in each Button's Events pane (the lightning bolt icon).
- Is the GUI clickable? Check this in the editor, in the GUI's Properties pane.
- Are the Buttons clickable? Check this in the editor, in each Button's Properties pane.
- Make sure that nothing in the script is changing the "Clickable" status of the GUI or the Buttons (anything setting Clickable to false for these items).
- Are the GUI and the Buttons enabled? Check this in the script (look for anything setting it to false).
- Check the cross-hair hotspot position of the mouse cursor in the editor. Make sure it is where you think it is.
- Are you using eModeWalkto? IIRC GUI- and GUIControl-clicks aren't registered for eModeWalkto.
- Finally, if all else fails, try adding a script breakpoint (press F9 with the cursor on the desired line) and/or, try using some run-time checks to make sure the OnClick event handlers are being called, for example:

Code: ags
function btnTalk_OnClick(GUIControl *control, MouseButton button)
{
  Display("btnTalk OnClick called!"); // is this ever displayed?
  // ...
}

Sickened

Alright, all your checks came out "positive" but I think I found the issue, however I still need some help. Basically, I had originally had a "Repeatedly Execute" script in the Global Script so that whenever the mouse button was pressed, the character would attack, and the keyboard controls movement, etc. All I did was take that script out and I could click on the GUI, the GUI would do it's thing, and I could click on the room and the character would walk to that position, which I DON'T want.

So, is there a way to maybe, if the cursor is above the coordinates of the GUI, to run the attack script, and then if it's under that point it would work with the GUI instead of attacking?

monkey0506

Do you want the character to attack repeatedly while the mouse is held down, or just once per mouse click? If you want him to only attack once per click then just use on_mouse_click instead of repeatedly_execute. Otherwise you can check GUI.GetAtScreenXY, which returns null if the coordinates are not over a GUI. For example:

Code: ags
GUI *gat = GUI.GetAtScreenXY(mouse.x, mouse.y);
if (gat == null)
{
  // attack code
}

SMF spam blocked by CleanTalk