Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Tamanegi on Sat 22/01/2011 04:10:47

Title: [solved] Clicking buttons without text or image?
Post by: Tamanegi on Sat 22/01/2011 04:10:47
Okay, my problem has changed, now I found out that my button clicks don't register because they have neither text nor graphics... but I need to have them there and have them clicked. Is there something I can do?
Title: Re: Clicking buttons without text or image?
Post by: monkey0506 on Sat 22/01/2011 07:43:46
You could do some boundary checking in on_event:

function on_event(EventType event, int data)
{
  if (event == eEventGUIMouseDown) // consider using eEventGUIMouseUp instead if it fits your needs better
  {
    if (data == btnNothing.OwningGUI.ID)
    {
      int xx = btnNothing.OwningGUI.X + btnNothing.X;
      int yy = btnNothing.OwningGUI.Y + btnNothing.Y;
      if ((mouse.x >= xx) && (mouse.x <= (xx + btnNothing.Width)) && (mouse.y >= yy) && (mouse.y <= (yy + btnNothing.Height)))
      {
        // ..clicked on btnNothing..do something here
      }
    }
  }
}
Title: Re: Clicking buttons without text or image?
Post by: Tamanegi on Sat 22/01/2011 15:50:13
Thanks, seems like this is the only solution... I thought that maybe there was an attribute I could change to do it.

I handled it by checking the coordinates of clicks on the GUI.