Titanium Community Questions & Answer Archive

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

Simulate a CLICK event to the Window leftnavbutton

Hi

I want to simulate a click event to the windows back button programtically..

I am using

Ti.App.fireEvent(win.leftNavButton, {name:'click'});

but it doesn't work.
Anything wrong with the statement?

— asked June 17th 2010 by Peter Lum
  • back
  • button
  • event
  • simulate
0 Comments

7 Answers

  • Does this not work?

    win.leftNavButton.fireEvent('click');
    
    — answered July 14th 2010 by Michael Stack
    permalink
    1 Comment
    • That worked for me, using the fireEvent to simulate a click on a button if a textfield wasn't empty and the return was received from the keyboard. Here is an example:

      buttonName.addEventListener('click', function (e) {
          alert("It Works!");
      });
      textField.addEventListener('return', function(e) {
          if (textField.value != '') {
               buttonName.fireEvent('click');
          }
      });
      

      — commented April 4th 2013 by Marcus Jordan
  • I don't think that's possible, unless i missed something from the api doc? The way I do this is just create a new function and drop all the code in there and just call it from the button and when you want to "programmatically" call the button. Does that make sense?

    — answered June 17th 2010 by Sj Singh
    permalink
    0 Comments
  • What i need is to "programmatically" call the button.
    How do you do it?

    — answered June 17th 2010 by Peter Lum
    permalink
    0 Comments
  • are you talking for android or iphone?

    rocksteady,
    danno~

    — answered June 17th 2010 by danno watts
    permalink
    0 Comments
  • iphone

    — answered June 17th 2010 by Peter Lum
    permalink
    0 Comments
  • It seems that the fireEvent functions are intended for passing messages between javascript execution environments, which does not appear to be the functionality you're after.

    I want to do similar stuff, trying to write some BDD style acceptance tests that are supposed to programmatically "drive" my application.

    Not having a lot of luck so far

    — answered April 19th 2011 by Travis Dixon
    permalink
    0 Comments
  • Did anyone find an answer to this?

    — answered November 2nd 2011 by David Shepheard
    permalink
    1 Comment
    • I believe that this functionality is not support in any recent version. Since this topic has been going for about 3 years now I wouldn't expect it added in.

      — commented April 4th 2013 by Sosh Howell
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.