-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make scroll view touch friendly #229
base: master
Are you sure you want to change the base?
Conversation
In my last commit I added event arguments to the TouchMoved, -Entered and -Left events where the ScrollViewer can hook up an callback that is only called if the touch event isn't handled. However there is still a lot to do. Probably not each case which handles the touch event sets the flag that the event was handled at the moment. Also a lot of the widgets process the TouchDown event instead of the TouchUp or combination of both.. Furthermore things like KeyBoardFocus are interferring at the moment. But: A ScrollViewer with a Slider in it already works as expected - TouchMove gestures in the ScrollViewer are processed as scrolling but TouchMove gestures on the Slider are processed by the Slider only. |
Made some larger refactorings but now it should be working. But I still need to test everything. What's not working at the moment is TextBox. I tried to remove most widget's logic from the OnTouchDown method to be able to scroll even if the touch gesture starts on a widget. For TextBox I think I need to undo those changes, differentiate between touch and mouse use or changing the behaviour of TextBoxes have to be focused first before one can interact with them. |
Hello,
|
Hmm the thing is those changes where needed to provide the new functionality.
The problem is to make a scrollviewer scrollable by touch gesture one needs to move most actions away from TouchDown (and also from from TouchUp) to a combination (that thing that I called Click). Therefore I splitted up the IsPressed state into actual IsPressed (the first usecase above) that is used for example for draggable things and therefore cannot be moved away from the TouchDown and TouchUp. And the second Property IsToggled that now acts on Click (TouchDown and TouchUp on same widget without moving outside the widget). I know that's a breaking change. If you want the IsPressed property as an obsolet property in your API we would need a second name for what is called IsPressed in this PR.. maybe IsPushed or IsPushedDown. But removing those changes from this PR to another makes the PR less useful since those changes were needed to make the scrolling work as I mentioned above.
As you can see I am not able to come up with another approach at the moment that I think is better. If you have an idea I am eager to know. On the other side I think creating one object per touch move is not as bad. EventArgs are quite common and only a small object - if really needed one could reuse the objects (but I would never suggest it as long as you are not creating hundreds of them). My HookableEventArgs is inspired by HandledEventArgs which is also made to get some feedback from the handlers to the system regarding the event was handled completely. However I liked it a bit more capsulated if one would like to change its functionality in future. Adding the possibility to add one callback makes it possible to handle ScrollViewers without going through the hierarchy two times and as long as the hierarchy is parsed from top to bottom it will also handle multiple ScrollViewers that are stacked into each other correctly. |
Just as a reminder for my todo list: |
@rds1983 I think I can split IsPressed into IsPressed and IsPushedDown in this PR here - and move the renaming of the other IsPressed properties and the marking as obsolete to another PR. This way there is not more than needed in this PR here but still it will be completely usable on its own. |
Sorry for the late response. |
Adds the capability to scroll in a ScrollViewer by drag touch gesture. In my first tests the scrolling is working.
However the interaction is still interpreted by the children widgets (e.g. I can scroll the ScrollViewer and drag a Slider inside the ScrollViewer at the same time). Can someone point me where I can fix this?
I tried to keep the overall architecture of ScrollViewer as it is. If everything works out and you are fine with the changes @rds1983 I think this should solve #87 .