Titanium Community Questions & Answer Archive

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

child view buttons

I have a window with a view in it. i add the buttons to the window to the main window on a double click :

win.addEventListener('doubletap', function(){
                win.add(next);
                win.add(done);
                win.add(back);
                win.add(home);
            });

when i switch the views and the buttons stay displayed but i have a hid buttons method:

done.addEventListener('click', function(){
        win.remove(next);
        win.remove(done);    
        win.remove(back);
        win.remove(home);
        });

when this method is called the buttons are not brought back with a double click the event is in the window and the views are subclassed of the window so the even listener should still work or am i missing something

— asked November 4th 2010 by a G
  • events
  • iphone
  • views
1 Comment
  • ok i found out if i hide them then it works but they are still clickable is there another solution than checking to see if they are hidden in the even listener

    — commented November 4th 2010 by a G

1 Answer

  • Your question is quite ambiguous, not least because you have missed out most of your code. Next time, formulate the most simple working code that demonstrates your issue and paste it to gist.

    You are correct that once the buttons have been removed from the view/window, their events should not be fired. Although I can't tell for certain what your issue is, be aware that every doubletap event to the view will bubble to (will be passed to, and fire again) the window, so the buttons will continue to be added even when they are already visible. In your case, I don't think it matters because the underlying code will just add the same buttons with no discernible result to the user. That said, you should bear this in mind when developing, or it could have undesired results, depending on what you are doing.

    Thus, it is better practice to store the state of the buttons (whether they have been added or removed). Take a look at this similar example from the KitchenSink.

    — answered November 4th 2010 by Paul Dowsett
    permalink
    0 Comments
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.