MR.Gestures handles ALL touch gestures

1356710

Posts

  • MichaelGeraceMichaelGerace Michael Gerace USMember

    @KeithRowe

    Just bind the image to scale properties in a viewmodel, and for the parent object of the image (ie the layout) set up some on pinching and onpinched which modify the scale by the deltapinch

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @KeithRowe

    The sample for the ContentPage in the GestureSample does exactly that. It handles the gestures on the ContentPage and shows an image which can be zoomed, rotated and dragged using the Pinching, Rotating and Panning gestures respectively.

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @SquallLeonhart.1032

    Sorry for not responding for so long. The problem turned out to be more complicated than I thought.
    It turns out that that's how Android handles the gestures. If you tap a cell, I raise the Down event of that cell. If you now move your finger up or down, then the ListView intercepts the gesture. This means that the gesture gets cancelled for the cell and the ListView receives all subsequent events. The cell is not informed of these anymore and so I cannot raise Up.

    I'll keep it on my todo list. Maybe I can find a workaround for it.

  • SquallLeonhart.1032SquallLeonhart.1032 Squall Leonhart USMember ✭✭

    @MichaelRumpler
    I need change the cell color to green if tap down and return to white when release.
    If you find any workaround please let me know. Thanks.

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @SquallLeonhart.1032

    You could listen to the Up event of the ListView and change the color of all cells back to white when that occurs.

  • KeithRoweKeithRowe Keith Rowe USMember

    @MichaelRumpler - Thanks for all your help on this. I got the sample working, but cannot port it over to my project.

    Attached are:

    • GestureSamplePinch - a version of your gesture sample with simply one screen, an image with OnPinching implemented
    • SampleAppWPinching - a sample app I am working on, that has the exact same code ported over but the OnPinching does not get called

    I have followed the installation instructions precisely, and the license says it isvalid after the license key is applied. I changed the app name in Windows Store to GestureSample - does it do follow up matching with the DLL or anything?

  • GaborFurediGaborFuredi Gabor Furedi HUMember ✭✭

    Just a non-tech question. Why didn't you release this on the Xamarin Component store? Due to the per-app licensing? Or was there any other factor that you didn't like?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @GaborFuredi

    Because the Xamarin Component Store cannot handle PCL projects. And thats the whole point of Xamarin Forms.

    I wanted to put it on the component store, but when I found out that they cannot do it and they didn't answer my email (still waiting for an answer to that mail from November), I started to think about a different licensing model.

    They still cannot do it. When I look at the DevExpress Grid for example, you have to add the component to each platform project separately and then add a reference to the PCL project manually. It is much easier to just open "Manage NuGet Packages for Solution", select one package and install it to all projects automatically at the same time.
    So NuGet was the way to go. After all, thats also what James Montemagno advocates here and here.

  • DavidRedmondDavidRedmond David Redmond AUMember ✭✭

    I bought this today and it's working great, very impressive library Michael!

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @KeithRowe

    In your sample solution the project "SampleCarousel.WinPhone" is for Windows 8.1 and not Windows Phone 8.1.
    And I get two errors when I try to compile:

    Could not find SDK "Microsoft.PlayerFramework.Xaml, Version=2.0.0.0".
    Could not find SDK "SQLite.WinRT81, Version=3.8.10.2".
    

    Could you please fix those.

    I don't have a touchscreen for my PC, so I cannot test the multitouch gestures on Windows 8.1. I can only test on WinPhone 8.1. They do share most of the code, so I do assume that it works on Windows when it works on WinPhone, but I can't be 100% sure.

  • KeithRoweKeithRowe Keith Rowe USMember

    @MichaelRumpler - Thank you for your help. I am now working on a different machine, and things seem to be working. I don't wonder if some of the issues are from working on a relatively immature Xamarin-WinStore combo. I'll let you know as I run into any more issues. Thanks again for all your help. For anyone wondering whether to buy, I strongly recommend given the good tech support and the troubles of writing custom renderers to handle these things without it.

  • GaborFurediGaborFuredi Gabor Furedi HUMember ✭✭

    @MichaelRumpler thanks for the info, very interesting!

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    I finally released the new version 1.2.0 a few minutes ago.

    This is the first release version with Windows Runtime support. It runs much smoother now compared to 1.2.0-pre1. It does not break anything anymore like pre1 did (scrolling did not work sometimes).

    This version is built upon Xamarin.Forms.1.4.3.6374 which also means that the Xamarin.Forms.Windows dependency is not needed anymore.

    If you have custom renderers on your own, then you don't need to inherit from mine anymore. It is now much easier to add the gesture functionality to your own renderers.

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    Somebody sent a tweet with a bug yesterday. On Android, if you used a MR.Gestures.ScrollView with Orientation="Horizontal", then it wouldn't scroll. A normal Xamarin.Forms.ScrollView worked as expected.

    I fixed that bug and released version 1.2.1. I also updated the GestureSample and added a test page there. It can be found in the app in Tests / Horizontal ScrollView.

  • RodyRody Rodolfo De Los Santos USMember ✭✭

    @MichaelRumpler I purchased a license for your Gestures package, but I used the project name instead of the app name by accident, so now I am unable to use it. Is there a way I can have that fixed?

    Thanks

    Rody

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @Rody

    I sent the new license key to your azure mailbox.

  • RodyRody Rodolfo De Los Santos USMember ✭✭

    @MichaelRumpler
    Thank you very much for the quick reply. It is working perfectly now. Excellent work with this package!

  • cleardemoncleardemon Bart King USMember

    @MichaelRumpler I seem to be having an issue with pinching on an image to zoom in and out of it. The actual pinching is very erratic and can even adjust the scale between extremes (e.g. going from 0.5 to 1.9 in a tiny finger movement).

    The same behaviour is visible in the GesturesSample app, on the ContentPage sample. In the simulator, just hold option and move the mouse up and down. Instead of being a small scale difference, it bounces around (though the rotation in the sample seems to mask the behaviour some what).

    Any idea what's going on there? In my code, I am using what it does in the sample app and experiencing the same problem (and it's more noticeable on an actual device).

  • KeithRoweKeithRowe Keith Rowe USMember

    @MichaelRumpler - When I implement a swipe gesture on a scroll view, the scrollview overrides the swipe (i.e. I am trying to implement a carousel view in a Windows Store app, and swipe should go from view to view but it doesn't because it scrolls the screen). Is there any way to override the scrollview with the swipe gesture?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @cleardemon

    I don't see that behavior in the ContentPage sample and nobody else reported that either.
    Which device are you using / simulating?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @KeithRowe

    Unfortunately that's a limitation of the ScrollViewer on Windows runtime. Rob Caplan explained that in his blog at http://blogs.msdn.com/b/wsdevsol/archive/2013/02/16/where-did-all-my-gestures-go.aspx and I also have some information about it at http://www.mrgestures.com/#Compatibility

  • MathiesonSterlingMathiesonSterling Mathieson Sterling USMember

    Not sure if this is the right place . . .

    @MichaelRumpler - I use MR Gestures and love it. However with left swipes the new iOS functionality considers that to be a back navigation. Is it possible to disable that for a page, or especially for a MR control. I.E. if the swipe is in my MRStackLayout container, don't let the OS consider it a navigation event?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @MathiesonSterling

    I did plan to use the Handled flag in the EventArgs for that. A gesture handler would set the flag to true to indicate that it would solely be responsible to handle the gesture. Unfortunately I couldn't get it to work reliably on all platforms.

    Some elements need to handle gestures themselves to work properly. Depending on the native implementation they could suppress the gesture events being forwarded to my library. One example for that is the swipe which is used for navigation also within a MasterDetailPage or the ScrollViewer in a Windows Runtime app (mentioned just 2 posts above).

    I always tried to keep existing functionality working. This means that my gesture handling works in parallel to any other gesture handling of other elements. As the Handled functionality does not work, I cannot suppress the gesture events to be forwarded to any other elements.

  • MathiesonSterlingMathiesonSterling Mathieson Sterling USMember

    Thanks for the quick response @MichaelRumpler - I'll look more into the iOS side then and see if can be disabled easily there.

  • JamesCGalindoJamesCGalindo James Galindo USMember

    Probably a dumb question but I am using ContentPages with StackLayouts and am currently displaying an Image in one of the StackLayouts. I have the out of the box TapGestureRecognizer wired up to the Image and it works fine but I need to know what part of the image the user has touched (x&y) ...will MR.Gesture provide that functionality? I have looked at the sample code but I'm not using XAML or ViewModels. Thank!

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @JamesCGalindo

    The TapEventArgs (and all other EventArgs) have a property called Touches. This is an array of Point which gives you the coordinates of all fingers currently touching the screen. See http://www.mrgestures.com/#EventArgs.

    You can add simple event handlers in code too. This is described here.

  • Optimus07Optimus07 Maniarasu V. INMember
    edited August 2015

    Panning the element only inside of its parent

    Referring MR.Gestures samples, we can move the element all over the screen using the "PANNING" event. And I tried to move the element only inside the parent block / element, but didn't got any luck. For example,

    Image 1 & 2 are the mr:Image with panning event. "Image 1" should move only inside of "Cell 1", currently we can move the "Image 1" inside "Cell 2" also. I tried to use the image inside with RelativeLayout and AbsoluteLayout. But still the image Overlapping in both Cells. Is there any way to move element only inside of its parent element?

  • AndriiTsokAndriiTsok Andrii Tsok UAMember ✭✭

    @MichaelRumpler do you have some code examples for your library and how to use it without inheritance to your base classes ?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @Optimus07

    When you start the gesture within Cell1, then the Panning events will be forwarded to the Cell1 handler until the gesture is over. You have to check the coordinates of PanEventArgs.Touches to decide whether to move the image.

    @AndriyTsok

    No, I still have to add those to the GestureSample. Didn't have the time to do it and there was no request for it yet.
    In the attached zip you can find my implementation of the BoxView and the renderers for all platforms. If you implement your own element like that, then it should work.

  • cleardemoncleardemon Bart King USMember

    @MichaelRumpler Cheers for responding, just got around to responding myself.

    I have created a simple test app that demonstrates the problem. Open the solution in XS, and set the Application Name under the iOS project to something that works with a license key, and set the actual license key in AppDelegate.

    Run the app in the simulator and a photo of a bird will appear. Hold option and click and drag over the image. It should scale up and down very erratically!

    ZoomableImage is the custom class that inherits from MR.Gestures.Image that simply adds event handlers to Pinching and Panning. I'm pretty much using code I copy-pasted from the GesturesSample app.

    Any thoughts on this one?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @cleardemon

    When you change the Scale during a gesture, then the touch coordinates cannot be calculated correctly. This same problem also exists when you do everything native without MR.Gestures.
    You should always add your gesture handlers to a container which will not be modified and change the Scale/Rotation/Translation of a subview only.

    You said in your previous post, that you have problems in the GestureSample too. Is this correct? If yes, then you need to tell me on which devices/simulators you got errors.

  • binayyadavbinayyadav binay yadav USMember ✭✭
    edited August 2015

    Hello All,
    I m moving a frame by using Panning gesture of MR Gesture,It's working but while panning it's blinking a lot.Doeas anybody know why this is happening.here is my panning event and view:

    Event:
    void Card_Panning(object sender, MR.Gestures.PanEventArgs e)
    {
    var deltax = e.DeltaDistance.X;
    var deltay = e.DeltaDistance.Y;
    try{

            //DisplayAlert ("panning", "panning called", "OK");
            var d = e.DeltaDistance;
            //info.Text = "x: " + d.X + ", y: " + d.Y;
            topCard.TranslationX += d.X;
            topCard.TranslationY += d.Y;
            }
            finally{
                //topCard.TranslationX = deltax;
                //topCard.TranslationY = deltay;
            }
        }
    

    topCard is the name of my mr:Frame control

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    @binayyadav

    It's the same answer I gave the previous poster.

    When you change the Scale during a gesture, then the touch coordinates cannot be calculated correctly. This same problem also exists when you do everything native without MR.Gestures.
    You should always add your gesture handlers to a container which will not be modified and change the Scale/Rotation/Translation of a subview only.

    So handle the Panning event in a container of topCard then it should work.

  • binayyadavbinayyadav binay yadav USMember ✭✭

    @Michael Thanks man..It worked for me :)

  • ZhenLuyingZhenLuying Zhen Luying USMember

    Hello Michael

    I hope to buy MR.Gesture. So, I tried it and payment is completed successfully, but I can't find the my key anywhere.
    Kindly help me.
    My email is luying.zhen@yandex.com

  • ZhenLuyingZhenLuying Zhen Luying USMember

    Hello Michael

    How can I receive the key of my app?
    What can I do?

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    Usually the key is printed on the web site and sent to you via email after the payment is completed. But the company who processes the payment and issues the license keys has problems with Chinese characters. I already told them months ago and they claimed to have fixed it. Unfortunately this seems to be wrong.

    However, I created and sent you your license key manually. I will also ask DigitalRiver to check their unicode processing again.

  • MichaelRumplerMichaelRumpler Michael Rumpler ATMember ✭✭✭✭

    I released version 1.2.2 of MR.Gestures.

    When you handled Panning, but not Panned, Pinching without Pinched or Rotating without Rotated, then the gestures were not properly ended and reset. Therefore when the next gesture started, the first EventArgs included some weird Delta* values. This has been fixed now.

  • MaheshJagtapMaheshJagtap Mahesh Jagtap USMember
    edited September 2015

    Thanks..
    It helped me lot

  • MaheshJagtapMaheshJagtap Mahesh Jagtap USMember
    edited September 2015

    Does it has any problem for Xamarin.Winphone?
    When i am registering it with
    MR.Gestures.WinPhone.Settings.LicenseKey = "Key";
    it gives exception
    An exception of type 'System.ApplicationException' occurred in MR.Gestures.WinPhone.DLL but was not handled in user code

    Additional information: The LicenseKey 'KEY-Key-Key..' is not for the app 'AppName.WinPhone'.

    One more thing, same key works for Android, iOS.

Sign In or Register to comment.