Page 1 of 1

stopPropogation not working

PostPosted: Fri Aug 26, 2016 2:51 pm
by RiaanPie
In my project I am creating some navigation buttons that make certain things happen in my "world". All working fine, except that there's a DropDown element underneath the buttons (hidden) that should slide out when the nav button is clicked. This too works, except for the fact that when you click over the place where the DropDown resides, it fires the "drop out" part of it.

I add the buttons like this:

Code: Select all
jsonQ.each(data, function (key, value) {
                      frame = btnCounter + (btnCounter + 1); // set initial frame
                      var t = navButtons.push(new NavButton()
                            .id(key)
                            .texture(textures[1])
                            .mount(self.topBar)
                            .translateTo(navPosX - offset, navPosY, 0)
                            .width(115)
                            .height(78)
                            .scale().x(.8)
                            .scale().y(.8)
                            .cell(frame)
                            );
                      navPosX += 128;
                      btnCounter++;
                  });


Then, the code in the Class looks like this:

Code: Select all
init: function () {
       IgeEntity.prototype.init.call(this);
       this.isActive = false;
      
      this.mouseOver(function(event, control){
          this.cell(this.getFrames(this._id) + 1);
      })
        .mouseOut(function(event, control){
            if (!this.isActive) this.cell(this.getFrames(this._id));
        })
      .mouseDown(function(event, control){
          if (!this.isActive) {
              this.setActive();
              setCat(this._id);
          }
          this.stopPropagation();
      });
   },


I have also tried both event.stopPropogation() and control.stopPropogation().

Thanks!

Re: stopPropogation not working

PostPosted: Fri Aug 26, 2016 3:11 pm
by rob
I wonder if it is due to mouseUp() firing?

Could you add a mouseUp event handler and stop propagation on that as well?

Re: stopPropogation not working

PostPosted: Tue Sep 06, 2016 10:54 am
by RiaanPie
Just to close off this topic, it was indeed the mouseUp that was firing. I stopped propogation on that event and its working as desired now.

Re: stopPropogation not working

PostPosted: Tue Sep 06, 2016 11:49 am
by rob
RiaanPie wrote:Just to close off this topic, it was indeed the mouseUp that was firing. I stopped propogation on that event and its working as desired now.


Awesome :)