6

I am new to mobile development with Titanium Studio. I would like to know if it is possible to transfer an event to a view's parent view.

For example, say that I have a imageview namely imgVw added on top of a view namely parentView and I want to pass the touch event of imgVw to parentView. Please let me know if it is possible. Thanks in advance.

senthil
  • 1,297
  • 1
  • 11
  • 22

2 Answers2

8

Please try this:

A simple technique is to set the touchEnabled property of child view to false, which passes the event to the parent view. Hope it helps.

suresh.g
  • 3,030
  • 5
  • 24
  • 58
1

you can create a custom eventListener. and you can fire that event when user touches the image view. and you can even pass the argument to the event.

in your parent View define a custom eventListener

Ti.App.addEventListener('imageTouch',function(e) {
  //This `e` will hold the  argument passed
});

now when you touch the Image view

add an eventListener to your ImageView to capture the touch event,

myImage.addEventListener('touch',function(e) {
     //Now fire your custom event here, this will take you to the custom 
     // event defined in your parent view
     Ti.App.fireEvent('imageTouch',{
        touchArg:[e] // here we save your touch callback in an array `touchArg` and pass this to the custom eventListener.
     });
 });

hope that helped :)

Ajeet Pratap Maurya
  • 4,224
  • 3
  • 26
  • 44