Can gestures be defined in the markup

Thread is closed for posting
6 posts, 0 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 11 Mar 2015 Link to this post

    So lets say I have a listview, and I want to have a widget in the listitem to accept a swipe...think like the iOS mail app.  Listview has itemTap, but pretty sure there's no item<Event> for each right?

    http://docs.nativescript.org/gestures.html#swipe

  2. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 11 Mar 2015 Link to this post

    Tried this on a Label and\or horizontal StackLayout, and nothing is triggered

    swipe="{{ onItemSwipe }}" tap="{{ onItemTap }}"
  3. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Mar 2015 Link to this post

    Hi Steve,

    You can get the data associated with the tapped item like this and you can declare gesture in XML like this. You need to have exported function in you code. 


    Regards,
    Vlad
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 12 Mar 2015 in reply to Vlad Link to this post

    Yeah, thats how I'm doing it...why would the functions not trigger?
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Mar 2015 Link to this post

    Hello,

    You can declared functions as bindings. If you have them in your code behind of the page you can simply set the name. For example:

    swipe="onItemSwipe" tap="onItemTap"

    Regards,
    Vlad
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 12 Mar 2015 in reply to Vlad Link to this post

    Oh yeah that was it!...was using databinding syntax not just giving it the name

    So tap works, but swipe doesn't...well I mean it DOES, but only a swipe left.

    exports.onItemSwipe = function(args){
        //dialogs.alert(args.direction);
        dialogs.alert("Swipe");
    }
        <ListView items="{{ items }}" row="2">
            <ListView.itemTemplate>
                <GridLayout columns="50, *, *, *, *, *" swipe="onItemSwipe">
    ...labels
                </GridLayout>
            </ListView.itemTemplate>
        </ListView>

    If I uncomment the args.direction line the app just outright crashes too 

    (this is iOS)
Back to Top