Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Ti.Gesture : how to RemoveEventListener on the right way ?

Hi again ^^(since Login work, i am very curious ;) )

I have my main Window ( with a GroupTab, etc..), and in my app, i have the Gesture Listener just for "ONE" view, so i made like KitchenSink with a Window "standalone" and EventListener on Gesture (orientationchange) to make the window apear.

This work. But when it work for the first time, it work always in every place on my app, which is not that i want.

I want to disable this "ListenerEvent" in other views, but i tried a lot of things to "removeListener", but never work.

The fact is that the Gesture Method can't be place in a particular view or other (maybe i'm wrong ^^), and is valid for all the application (because of the call style : Titanium.Gesture.addEventListener)

So do you know how to remove correctly the event and Gesture function ?

I tried this in other views to disable the gesture :

//Make Error

//Other code i tried, but also make error
Ti.Gesture.removeEventListener("orientationchange", "functionName");

I don't know how to remove simply an Event i suppose, never see a right exemple even on KitchenSink….

Thank you for your help ^^

— asked April 19th 2010 by Vivien Brissat
  • eventlistener
  • iphone
  • orientationchange
  • ti.gesture

3 Answers

  • Accepted Answer

    Hi Vivien,

    The second way you're trying it should work okay, I just did a quick test and it worked for me. When you try to remove the event listener are you actually putting quote around the function name? If you are, remove those and try it again. So like this to add the listener:

    Ti.Gesture.addEventListener('orientationchange', changed);
    function changed() {
        Ti.API.info('orientation has changed');

    …and like this to remove it:

    Ti.Gesture.removeEventListener('orientationchange', changed);
    — answered April 20th 2010 by Dan Giulvezan
  • Hi !!

    Allright i will try, this more explicit for me now ;)

    I didn't try without quotes (always see this kind of functions with quotes ^^)

    Thank you for the exemple, it makes sense for me now ^^

    — answered April 20th 2010 by Vivien Brissat
  • Hi,

    Mine is also similar solution thing is i have a screen on landing only i will be showing in "Landscape" mode on orientation change screen should close, All other screens in App are in "Portrait" mode.

    Can anyone help me in removing the event listener in screen.

    Thanks in Advance.

    — answered February 5th 2015 by Rakesh Kalwa
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.