I'm trying to get interactive gesture recognition (specifically, zooming and panning) working for my Delphi / C++Builder 10.2 Tokyo app.
What I've done so far:
Add a TGestureManager, GestureManager1 to my form.
Set the form's Touch.GestureManager to GestureManager1.
Leave everything under Touch.Gestures unchecked, because I want interactive gestures (zoom and pan), not "standard" gestures.
Make sure that Touch.InteractiveGestures.igZoom is checked.
Assign an OnGesture event handler.
The OnGesture event handler is triggered as expected, but the event's EventInfo.GestureID (which is supposed to give the type of gesture - pan, zoom, etc.) is always 0.
What am I doing wrong?
"Standard" gestures (the various lines and shapes under Touch.Gestures.Standard and "interactive" gestures (panning, zooming, rotating) are mutually exclusive.
To process "standard" or "custom" gestures", add a TGestureManager.
To receive "interactive" gestures, you need to remove the TGestureManager. This Embarcadero DocWiki article, which explains how gestures work in VCL and FireMonkey, specifically says:
In order to use Interactive Gestures such as zoom and rotate in a component, you do not need to associate the component with a Gesture Manager.
This Intel article has more details on Windows' various gesture interfaces. What Delphi calls "interactive" gestures correspond to Windows' WM_GESTURE message.
Related
I see that the SingleChildScrollView allows scrolling via the MacBook trackpad with two-finger-panning.
However, I cannot find any gesture recogniser that is triggered by two-finger-panning.
How is two-finger-panning implemented for SingleChildScrollView?
I found the answer. Scrollable listens to PointerScrollEvent.
https://github.com/flutter/flutter/blob/b007a81ad498eb9b7cd687fda0aa9d8d2bb77dc3/packages/flutter/lib/src/widgets/scrollable.dart#L642
However, there is no reliable way to detect when scrolling actually ended and is not just idle (the user lifted the fingers).
Is there reliable/official way to completely disable user interaction with the view? Similar SO questions only suggest intercepting mouse events, but I'm looking for a complete solution, which will disable all interactions in view and it's descendants, including:
mouse events
trackpad
keyboard focus/events
accelerator keys
voice input
mind control techniques
whatever other official way for user to spawn control events from the UI
The view (and it's descendants) should also immediately lose keyboard/mouse focus once interaction is disabled.
This should be similar to what transitionFromViewController:toViewController:options:completionHandler: does without NSViewControllerTransitionAllowUserInteraction flag, but I can't find a way to do that outside an animation.
Update:
The other way to describe what I'm looking for is: view must act totally like it's hidden, but still be drawn on screen.
I've run in a bit of a pickle with my puzzle game for windows phone.
I want to change between two adjutant rectangles, both on the same grid.
The tap event was easily implemented, but implementing drag seems to be a really big pain.
I'm also using a custom user control to get the rectangles on the grid, so i need to create custom delegates before attaching events to my rectangle matrix.
I am currently using the manipulation completed and manipulation started events to implement the drag gesture, but there are a couple of problems:
1) i have to tell the difference between tap and actual drag, both which are covered by the manipulation completed event. This is the way I do it right now:
if (e.TotalManipulation.Translation.X == 0 && e.TotalManipulation.Translation.Y == 0)
{
}
else
{do drag stuff here}
however, the do drag stuff here part does not seem to work, even if the transitions are different from 0; It always executes the tap event.
I am currently stacked in using manipulation events, because, as i said, I am using a custom control as an object prototype for my rectangle matrix, and i need custom delegates for that, and apparently, the GestureListener has no constructors for its event classes.
So, any suggestion on how to do this?
I figured the answer just after posting this question.
You can actually attach a gesture listener to a custom control and create custom delegates, by sending the drag gesture event parameter from the gesture listener drag event to the delegate you create and it works.
XCode 4 (but also iTunes and other Mac apps) provide side or bottom bars that can be shown or hidden with a smooth animation as the user presses a button.
How can I obtain a similar effect in my applications?
You can use NSSplitView to do that. You can have more than 2 subviews in a split view (left|center|right) and you can build a kind of hierarchy for the different bars (center consists of top and lower split views).
The show/hide effect is not built in, though. But you should be able to use the animator to do that. Most certainly you can also define animations for hiding a view.
You could also use the BWSplitView of http://brandonwalkin.com/bwtoolkit/ where the show/hide animation is already included.
You could also consider subclassing NSViewAnimation, which I believe Xcode uses in a number of places to achieve its fancy animation effects.
I am using a custom panel as a ItemsPanel for a ItemsControl in a with a custom template that provides for a scroll viewer. (See Xaml below.) So long as my panel does not implement IScrollInfo, scrolling works in this scenerio.
I implement IScrollInfo and update my viewport and extent sizes in measure override. The scroll bar shows the correct relative size, and if I call the IScrollInfo methods directly, scrolling works as expected. However, the drag and flick gestures no longer scroll the content. Putting a breakpoint on the input of every IScrollInfo method shows that drag and pick are not calling the interface. Removing the IScrollInfo interface declaration restores the scroll on drag and flick behavior.
Is there a simple way to restore the flick and pan gestures to ItemControls with panels that implement IScrollInfo?
An unfortunate answer I received from Eric Sink, A MSFT forum moderator.
I believe that what is happening is that, when you inherit from
IScrollInfo, your panel takes over all of the scroll functionality but
we use an internal interface, as martin mentioned, to control the
flick animation. Since your object does not inherit from this
interface the underlying code will bypass this functionality.
I think that you should still be able to override the OnManipulation*
events and setup your own storyboard animation.
It sounds like if you want to do IScrollInfo, you're on your own for the manipulation.