alexrainman / nativescript-carousel-view

CarouselView plugin for NativeScript
MIT License
16 stars 5 forks source link

Tap not firing on label inside slide #8

Closed terreb closed 7 years ago

terreb commented 7 years ago

nativescript 2.3.0 tns-core-modules 2.3.0 tns-ios 2.3.0 nativescript-carousel-view 2.0.1 simulator iOS 9.3

How to reproduce:

  1. Change slider-view.xml in the demo app to:
<StackLayout loaded="onLoaded" horizontalAlignment="center" padding="12">
    <Label text="{{ first }}"/> 
    <Label text="{{ last }}" tap="test"/>
    <Button text="Remove me" tap="buttonTap"/> 
</StackLayout>
  1. Add handler to slider-view.ts
export function test() {
    console.log('TEST')
}
  1. Run the demo, tap on last name, see whether console prints 'TEST'
alexrainman commented 7 years ago

@terreb label doesn't have tap event. To attach events to label you have to use gestures http://docs.nativescript.org/api-reference/classes/_ui_label_.label.html

alexrainman commented 7 years ago

https://docs.nativescript.org/cookbook/ui/gestures

terreb commented 7 years ago

As you probably already found out by yourself tap event is working on labels outside your plugin. So, why the issue is closed?

alexrainman commented 7 years ago

Version 2.0.2 released. Now you can use onLoaded() to hook up tap event to labels.

https://docs.nativescript.org/cookbook/ui/gestures

alexrainman commented 7 years ago

Actually, closing this was the right thing. Label tap works both with a function in code behind and with bindings. Maybe fixing onLoaded() fixed that too? Thanks

terreb commented 7 years ago

I don't know, but it works like a charm now! Thanks a lot!