2D Toolkit Forum

2D Toolkit => Support => Topic started by: nemoryoliver on May 11, 2013, 05:53:58 am

Title: any 2k2d button down event? only fires after button up
Post by: nemoryoliver 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.
Title: Re: any 2k2d button down event? only fires after button up
Post by: unikronsoftware 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.
Title: Re: any 2k2d button down event? only fires after button up
Post by: nemoryoliver on May 11, 2013, 04:25:36 pm
Worked like a charm. Thank you so much. :)