Hello Guest

Author Topic: any 2k2d button down event? only fires after button up  (Read 3115 times)

nemoryoliver

  • Newbie
  • *
  • Posts: 10
    • View Profile
any 2k2d button down event? only fires after button up
« on: May 11, 2013, 05:53:58 am »
I am using a 2k2dButton and realized it only fires the SendMessage function after button up. Any suggestions please? thank you.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: any 2k2d button down event? only fires after button up
« Reply #1 on: May 11, 2013, 02:55:16 pm »
You have the source code to tk2dButton - you can easily move the lines which trigger the button press
Code: [Select]
if (targetObject)
{
targetObject.SendMessage(messageName);
}
... to wherever you need it to be.

Eg. If you want to trigger as soon as its pressed, move it to the top of that function, right under the first occurrence of this:
Code: [Select]
if (ButtonDownEvent != null)
ButtonDownEvent(this);

Or you could use the 2D Toolkit UI button class, which has event triggering for the other options too.

nemoryoliver

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: any 2k2d button down event? only fires after button up
« Reply #2 on: May 11, 2013, 04:25:36 pm »
Worked like a charm. Thank you so much. :)