Sha256: bca9f11fe0febcfb8c3d7d9711627cc269c6dcdd824dea9dbfb2f3bb0d3cbd92

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

sc_require('views/template');

SC.Button = SC.TemplateView.extend({
  classNames: ['sc-button'],

  // Setting isActive to true will trigger the classBinding and add
  // 'is-active' to our layer's class names.
  mouseDown: function() {
    this.set('isActive', true);
    this._isMouseDown = YES;
  },

  mouseExited: function() {
    this.set('isActive', false);
  },

  mouseEntered: function() {
    if (this._isMouseDown) {
      this.set('isActive', true);
    }
  },

  // Setting isActive to false will remove 'is-active' from our
  // layer's class names.
  mouseUp: function(event) {
    if (this.get('isActive')) {
      var action = this.get('action'),
          target = this.get('target') || null,
          rootResponder = this.getPath('pane.rootResponder');

      if (action && rootResponder) {
        rootResponder.sendAction(action, target, this, this.get('pane'), null, this);
      }

      this.set('isActive', false);
    }

    this._isMouseDown = NO;
  },

  touchStart: function(touch) {
    this.mouseDown(touch);
  },

  touchEnd: function(touch) {
    this.mouseUp(touch);
  }
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sproutcore-1.6.0.beta.3-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.beta.3-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.beta.3 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.beta.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.beta.2-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.beta.2 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js