RonenNess / GeonBit.UI

UI system for MonoGame projects.
MIT License
467 stars 63 forks source link

Question regarding touch #97

Closed mylemans closed 5 years ago

mylemans commented 5 years ago

I'm considering implementing support for touch, but I'm wondering how far I should take things.

Seeing the source, it looks like it assumes there can be only one active element at the moment, but when dealing with touch input, you could have multiple touch points at the same time.

So question is how to deal with it, or in short, what do you expect to happen when 2 fingers are pressing down on a button. Both pressed down, only the 'first' (whatever the system thinks is first) or none?

RonenNess commented 5 years ago

Hi @mylemans,

To implement touch you need to create an alternative mouse input manager:

https://github.com/RonenNess/GeonBit.UI#imouseinput

And implement it with touch input. As you can see from the class's API

https://github.com/RonenNess/GeonBit.UI/blob/master/GeonBit.UI/Source/Input/IMouseInput.cs

It only support single position source. So its up to you and how you implement it, you can choose the first touch or the latest touch, but in the end GeonBit.UI only support one mouse-like input source.

Change it might be tricky but if you want to take that challenge I can help you with questions.

Does it answer your question?

mylemans commented 5 years ago

I'm considering the challenge to add multi touch support, if there is no real objection on your end to not do it that is.

RonenNess commented 5 years ago

Ofc I wouldn't mind, but I can't guarantee to merge it, especially if it adds complication / change code too drastically.. May I ask why you need multi-touch in UIs? If its for gestures there's probably better way to achieve that (like emulating scrolling events from pitch, etc), if you actually want to allow users to press multiple buttons at the same time - I have to ask - why? :)

mylemans commented 5 years ago

Mostly to be complete. But I'll see what I can do.

Edit: What I could do is adding support for a single touch as default mode, and then separate logic for multitouch that would be opt-in. I might implement both separately though, don't think I want to 'enhance' the mouse input service. Maybe another service that interacts with this input service to simulate activity.

I'll have a better look this weekend.

RonenNess commented 5 years ago

Ok sure, feel free to ask questions if you have any. But to be honest if I were you I wouldn't even bother with it. Using two UI elements at the same time is rarely needed, unless you want to implement your games movement handle inside GB.UI which I would advice against it..