Sha256: 0dc9a4db04c6324098d4be7121abe6437d64514d203c71cbd5b3931fc0a4335e

Contents?: true

Size: 1.83 KB

Versions: 12

Compression:

Stored size: 1.83 KB

Contents

/**
  @class

  @extends SC.ButtonView
  @author Santosh Shanbhogue
  @copyright 2008-2009, Sprout Systems, Inc. and contributors.
  @version 1.0
*/
sc_require('views/button');
SC.PopupButtonView = SC.ButtonView.extend({
  /**
    This property shows whether the menu is currently displayed or not
  */
  keyEquivalent: null,
  classNames: ['sc-popup-button'],
  
  /**
    Prefer matrix to pass the offsets to position the pane popped up by this 
    button.
    
    @property
  */
  preferMatrix: null,
    
  /**private */
  acceptsFirstResponder: YES,
  /**
    Overriding the default SC.ButtonView#performKeyEquivalent method to pass 
    it onto the menu
    
    @param {string} keystring method name corresponding to the keys pressed 
    (i.e alt_shift_z)
    @param {DOMMouseEvent} evt mousedown event
  */
  isSelected: NO,
  performKeyEquivalent: function( charCode, evt )
  {
    if (!this.get('isEnabled')) return NO ;
    var menu = this.get('menu') ;
    return (!!menu && menu.performKeyEquivalent(charCode, evt)) ;
  },
  
  /**
    Menu attached to the popupButton
    @default SC.MenuView
  */
  menu : null,
  
  /**
    Binds the button's selection state to the menu's visibility.
    @private
  */
  isSelectedBinding: '*menu.isVisibleInWindow',
  
  /**
    Button action handler
    @param {DOMMouseEvent} evt mouseup event that triggered the action
  */
  action: function( evt )
  {
    var menu = this.get('menu') ;
    // no menu to toggle... bail...
    if (!menu) return NO ;
    menu.popup(this, this.preferMatrix) ;
    return YES;
  },
  
  /**
    @private

    Holding down the button should display the menu pane.
  */
  mouseDown: function(evt) {
    if (!this.get('isEnabled')) return YES ; // handled event, but do nothing
    this.set('isActive', YES);
    this._isMouseDown = YES;
    this._action() ;
    return YES ;
  }
  
});

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sproutcore-1.0.1037 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1035 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1031 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1030 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1029 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1027 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1028 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1026 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1025 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1024 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1009 frameworks/sproutcore/frameworks/desktop/views/popup_button.js
sproutcore-1.0.1008 frameworks/sproutcore/frameworks/desktop/views/popup_button.js