Results 1 to 6 of 6
  1. ietv's Avatar
    Posts
    7 Posts
       #1  
    When tapped, I want the button label to change to a random number, and add the number value of the previous label to the number value on the label on adjacent buttons, then update the labels on these adjacent buttons.

    But the onTap handler is running twice for every tap, according to the log info. I tried setting the onCapture boolean in this.controller.listen, but I get an error in the log: "Error: TRUE is not defined, line undefined, file undefined". It seems to work, though, but just for that button! The button listener immediately following the button with the TRUE boolean stops working.

    If I set the boolean to 1, I get no error messages in the log, but it also doesn't seem to do anything - the onTap handler runs twice.

    What is going on?
  2. #2  
    Quote Originally Posted by ietv View Post
    When tapped, I want the button label to change to a random number, and add the number value of the previous label to the number value on the label on adjacent buttons, then update the labels on these adjacent buttons.

    But the onTap handler is running twice for every tap, according to the log info. I tried setting the onCapture boolean in this.controller.listen, but I get an error in the log: "Error: TRUE is not defined, line undefined, file undefined". It seems to work, though, but just for that button! The button listener immediately following the button with the TRUE boolean stops working.

    If I set the boolean to 1, I get no error messages in the log, but it also doesn't seem to do anything - the onTap handler runs twice.

    What is going on?
    What exact event are you listening for in this.controller.listen()?

    You should be listening for Mojo.Event.tap

    Also, in JavaScript, you must write it true or false, no caps allowed.
    Arthur Thornton

    Former webOS DevRel Engineer at Palm, HP, and LG
    Former webOS app developer (built Voice Memos, Sparrow, and several homebrew apps and patches)
    Former blogger for webOS Nation and webOS Roundup
  3. ietv's Avatar
    Posts
    7 Posts
       #3  
    Quote Originally Posted by arthurthornton View Post
    What exact event are you listening for in this.controller.listen()?

    You should be listening for Mojo.Event.tap

    Also, in JavaScript, you must write it true or false, no caps allowed.
    Listening for Mojo.Event.tap. Here's the code:
    Code:
    this.controller.listen("r1c2button", Mojo.Event.tap, this.r1c2buttonTap.bind(this), true);
    This doesn't prevent the adjacent buttons from working like "TRUE" does, but it also doesn't prevent the onTap handler for that button from running twice.

    Here's the code for the handler:

    Code:
    r1c2buttonTap: function(inSender, event) {
    	this.numdelta = Number(this.r1c2Model.label);
    	Mojo.Log.info("tap r1c2 numdelta ", this.numdelta);
    	this.numr1c2 = Math.floor(Math.random() * 10);
    	Mojo.Log.info("tap r1c2 random r1c2 ", this.numr1c2);
    	this.numr2c2 = Number(this.r2c2Model.label) + this.numdelta;
    	Mojo.Log.info("tap r1c2 numr2c2 ", this.numr2c2);
    	this.numr3c2 = Number(this.r3c2Model.label) + this.numdelta;
    	Mojo.Log.info("tap r1c2 numr3c2 ", this.numr3c2);
    	this.numc2result = this.numr1c2 + (this.op1 * this.numr2c2) + (this.op2 * this.numr3c2);
    	Mojo.Log.info("tap r1c2 new column 2 total is ", this.numc2result);
            Mojo.Log.info("============== end tap r1c2 ===========================");
            this.winCheck();		
    },
  4. ietv's Avatar
    Posts
    7 Posts
       #4  
    And here's another question: If I add the onCapture boolean to the listener, do I also need to add it to the cleanup function?
  5. ietv's Avatar
    Posts
    7 Posts
       #5  
    I posted a reply with code, but apparently posts with code need to be approved by a moderator. Anyway, I am listening for Mojo.Event.tap, and using "true" instead of "TRUE". But it doesn't keep it from firing twice.
  6. ietv's Avatar
    Posts
    7 Posts
       #6  
    Also want to mention that I thought the problem was that the Mojo.Event.tap was calling the handler both as it bubbled up to the top level of the DOM, and then as the DOM sent the event back down the chain, but if the onCapture boolean is working on the listener, then that's not what's happening. If it's not caused by the bubble/send events, then I'm at a complete loss of why it might be happening, unless it's a problem with the emulator.

Posting Permissions