Binding Tap event to Label in RadDataForm


#1

I am trying to bind a tap event to Label control of RadDataForm but no luck as I am not aware of Objective C. need help urgently.


#2

I guess we discussed same in another thread. You can’t bind events with DataForm components like you do with NativeScript core components. You can add listeners natively once a editor is created or the easiest way is to inject a custom control.


#3

Thanks, yeah that is what I mean, I was successful in adding Tap listener to RadDataFrom’s Label element using native android code (see example below), want same functioanlity on ios platform. Custom control will be an over kill and out of question.

    const that = this;
        editor.getEditorView().setOnClickListener(new android.view.View.OnClickListener({
          onClick(view: android.view.View) {
            that.handleTap(view, args.object);
          }
        }));

#4

Make sure you run this set of code in iOS only.

@ObjCClass()
class TapHandler extends NSObject {

    private callback: Function;

    static initWithCallback(callback) {
        const tapHandler = TapHandler.new() as TapHandler;
        tapHandler.callback = callback;
        return tapHandler;
    }

    @ObjCMethod()
    public tap( @ObjCParam(UITapGestureRecognizer) sender: UITapGestureRecognizer) {
        this.callback();
    }
}
....
....
   const tapHandler = TapHandler.initWithCallback(() => {
        alert("Tapped");
    });
    editor.addGestureRecognizer(UITapGestureRecognizer.alloc().initWithTargetAction(tapHandler, "tap"));
    (<any>editor)._tapHandler = tapHandler;

RadDataForm put tap event to label of a field
#5

how to use this in nativescript angular project?