This is a migrated thread and some comments may be shown as answers.

Can gestures be defined in the markup

5 Answers 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 11 Mar 2015, 07:32 PM
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

5 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 11 Mar 2015, 07:42 PM
Tried this on a Label and\or horizontal StackLayout, and nothing is triggered

swipe="{{ onItemSwipe }}" tap="{{ onItemTap }}"
0
Vlad
Telerik team
answered on 12 Mar 2015, 06:34 AM
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.

 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Mar 2015, 08:40 AM
Yeah, thats how I'm doing it...why would the functions not trigger?
0
Vlad
Telerik team
answered on 12 Mar 2015, 08:51 AM
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.

 
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Mar 2015, 01:00 PM
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)
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Vlad
Telerik team
Share this question
or