Hello Guest

Author Topic: UI - how to get an event for a touch moving into a widget ?  (Read 3404 times)

play-i

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
UI - how to get an event for a touch moving into a widget ?
« on: April 21, 2014, 05:08:00 pm »
Hi -

unity & 2dtk noob here, so apologies if this is covered ground.

I'd like to be able to get an event on a button when a touch that is already down moves into the button.

Eg: touch down in empty space, then slide into the button.
Another example would be touching down in the button (we get OnDownUIItem), then slide out into empty space (we get OnUpUIItem), then slide back in (we get nothing).

Without this, it's impossible to build say a piano keyboard UI which allows the user to do a glissando.

These events would maybe be named "OnEnter" and "OnExit" or something.

this may be similar to this post: http://2dtoolkit.com/forum/index.php/topic,3515.msg16836.html .

cheers,
Orion

play-i

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: UI - how to get an event for a touch moving into a widget ?
« Reply #1 on: April 21, 2014, 05:51:46 pm »
I tried adding an UpdateTouch() method, but it doesn't seem to be be getting fired (either in Unity or on iOS simulator).
The class is structured like this:

Code: [Select]
public class KeyboardButton : tk2dUIBaseItemControl {
...
public void UpdateTouch(tk2dUITouch touch) {
Debug.Log("touch");
}
...
}

I guess an approach could be to go through tk2dUIManager:CheckInputs() and track an additional item called "enteredUIItem" or similar,
and a bool in tk2dUIItem called "isEntered", etc.  Would need to modify CurrentOverUIItem() as well. Seems like a fair bit of patching.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: UI - how to get an event for a touch moving into a widget ?
« Reply #2 on: April 22, 2014, 03:05:40 pm »
This isn't officially supported and yes it'll need a bit of patching in. This has been requested in the past and is in the roadmap (https://trello.com/c/GtTCPbJq/45-hover-support-with-multitouch-finger-dragged-into-a-control-without-being-tapped) but hasn't really received very many votes.

It can be handled the same way hover is handled right now.

play-i

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: UI - how to get an event for a touch moving into a widget ?
« Reply #3 on: April 22, 2014, 04:32:21 pm »
hey - thanks for the reply.
I voted for the trello card. Meanwhile if our need is strong enough I'll try patching it in myself.
cheers,
Orion