Results 1 to 8 of 8
  1. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
       #1  
    so I have a function for handling a button press:

    FirstAssistant.prototype.handleButtonPress = function() { ...}


    it has been bound to the button listener, and that works just fine. what I want to do is call this function when the application is first loaded (essentially simulating a button press)

    i assume this needs to go in FirstAssistant.prototype.setup

    I have tried all of the following, and none seem to work, most give an error on the log

    these result in an error:

    handleButtonPress()
    this.prototype.handleButtonPress()
    FirstAssistant.prototype.handleButtonPress()


    this doesn't give an error, but nothing happens:

    this.prototype.handleButtonPress.bind(this)


    I am pretty sure I've tried tons of other combination (including (this) or not, etc.) nothing seems to work. I think my lack of javascript knowledge is starting to catch up with me in webOS development I did not know javascript before I started trying to develop for WebOS. I have only been at it for about 3 days. I am sorry if this is simple or doesn't make any sense.

    thanks!
  2. #2  
    Code:
    this.handleButtonPress();
    should work as long as you have this function:

    Code:
    FirstAssistant.prototype.handleButtonPress = function(){
    
    <stuff it does>
    
    }
    My site: Shanerooni, LLC
    Follow me on Twitter
    My apps: GuessWhat? | MazeHunter3D | Small Wonders | PhakePhoney | AutismAware | PicSketcher | Cubix | QuickSolve | QuickSpell | QuickTrace | QuickWhack | QuickSuite | Soccer Shots | Ballooning |
    Cubix
  3. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
       #3  
    Quote Originally Posted by shanerooni View Post
    Code:
    this.handleButtonPress();
    should work as long as you have this function:

    Code:
    FirstAssistant.prototype.handleButtonPress = function(){
    
    <stuff it does>
    
    }
    ok, so when I still am getting an error, but now I realize it's actually running the function. The error said there was a problem with the setup function, so that was confusing me.

    It looks like it's getting to the function, but in that function I make reference to the button by saying this.controller.get('activityButton').mojo.activate()

    and this is actually what's failing.

    any ideas?
  4. #4  
    do you have a button with an I'd "activityButton"
  5. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
       #5  
    yes, when pressing the button, everything works just great and dandily. I just want to simulate a button press as soon as the app loads up. the error from the log says:

    [20100507-13:58:00.088459] error: An exception occurred in the 'first' scene's setup() method.
    [20100507-13:58:00.089759] error: Error: Cannot call method 'get' of undefined,line undefined, file undefined
  6. #6  
    make sure your this.handleButtonPress(); is the last thing in the setup. you may having something that has not yet been defined in the setup that is required in the function to run it the first time from the setup function.
    My site: Shanerooni, LLC
    Follow me on Twitter
    My apps: GuessWhat? | MazeHunter3D | Small Wonders | PhakePhoney | AutismAware | PicSketcher | Cubix | QuickSolve | QuickSpell | QuickTrace | QuickWhack | QuickSuite | Soccer Shots | Ballooning |
    Cubix
  7. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
       #7  
    Quote Originally Posted by shanerooni View Post
    make sure your this.handleButtonPress(); is the last thing in the setup. you may having something that has not yet been defined in the setup that is required in the function to run it the first time from the setup function.
    it's towards the end. It's inside of an if statement.

    I have an if statement checking for the existence of a cookie. if the cookie exists, it gets the info and is supposed to simulate a button press. if the cookie doesn't exist, it shows a dialog asking for the info. this info is then saved into a cookie, so it will never show up again. ultimately, I would like to simulate a button press here too.

    anyway, the if statement is the last thing int the setup function. so the only thing that comes after this.handleButtonPress(); is the case of no cookie.
  8. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
       #8  
    got it!!

    out of sheer curiosity, I went ahead and put it inside of

    FirstAssistant.prototype.activate = function(event) {
    this.handleButtonPress();
    }


    and that worked perfectly


    EDIT - almost perfectly, lol. now, even if you don't have a cookie (on the first run of the app) it still simulates a button press... which is bad, since there is no info. I think I can fix this with a firstrun flag or something.

    EDIT2 - yup, that worked.

    now.. to make it also simulate a button press after it creates the cookie...
    Last edited by pomokey; 05/07/2010 at 01:34 PM.

Tags for this Thread

Posting Permissions