/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\beads\HideComboPopupOnMouseDownBead.as
 * org.apache.royale.html.beads.HideComboPopupOnMouseDownBead
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.beads.HideComboPopupOnMouseDownBead');

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.events.MouseEvent');
goog.require('org.apache.royale.html.beads.IComboBoxView');
goog.require('org.apache.royale.utils.callLater');
goog.require('org.apache.royale.utils.loadBeadFromValuesManager');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.utils.Language');



/**
 * @constructor
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead = function() {
};


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.beads.HideComboPopupOnMouseDownBead', org.apache.royale.html.beads.HideComboPopupOnMouseDownBead);


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand;


/**
 * @protected
 * @type {org.apache.royale.html.beads.IComboBoxView}
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.viewBead;


/**
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.finishSetup = function(event) {
  if (this.viewBead == null) {
    this.viewBead = org.apache.royale.utils.Language.as(org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.html.beads.IComboBoxView, "iBeadView", this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand), org.apache.royale.html.beads.IComboBoxView);
  }
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.events.IEventDispatcher, true).addEventListener("show", org.apache.royale.utils.Language.closure(this.handlePopupShow, this, 'handlePopupShow'));
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.events.IEventDispatcher, true).addEventListener("hide", org.apache.royale.utils.Language.closure(this.handlePopupHide, this, 'handlePopupHide'));
};


/**
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.handleControlMouseDown = function(event) {
  event.stopImmediatePropagation();
};


/**
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.handlePopupShow = function(event) {
  var self = this;
  var /** @type {Function} */ __localFn0__ = function() {
    org.apache.royale.utils.Language.as(self.viewBead.popUp, org.apache.royale.core.IUIBase, true).topMostEventDispatcher.addEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(self.handleTopMostEventDispatcherMouseDown, self, 'handleTopMostEventDispatcherMouseDown'));
  }
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.events.IEventDispatcher, true).addEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand, org.apache.royale.events.IEventDispatcher, true).addEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  org.apache.royale.utils.callLater(__localFn0__);
};


/**
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.handleTopMostEventDispatcherMouseDown = function(event) {
  this.viewBead.popUpVisible = false;
};


/**
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.handlePopupHide = function(event) {
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.events.IEventDispatcher, true).removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand, org.apache.royale.events.IEventDispatcher, true).removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.core.IUIBase, true).topMostEventDispatcher.removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleTopMostEventDispatcherMouseDown, this, 'handleTopMostEventDispatcherMouseDown'));
};


org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand = value;
  this.viewBead = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand.getBeadByType(org.apache.royale.html.beads.IComboBoxView), org.apache.royale.html.beads.IComboBoxView);
  if (this.viewBead) {
    this.finishSetup(null);
  } else {
    org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_HideComboPopupOnMouseDownBead__strand, org.apache.royale.events.IEventDispatcher, true).addEventListener("viewChanged", org.apache.royale.utils.Language.closure(this.finishSetup, this, 'finishSetup'));
  }
};


Object.defineProperties(org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype, /** @lends {org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'HideComboPopupOnMouseDownBead', qName: 'org.apache.royale.html.beads.HideComboPopupOnMouseDownBead', kind: 'class' }], interfaces: [org.apache.royale.core.IBead] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.HideComboPopupOnMouseDownBead.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.html.beads.HideComboPopupOnMouseDownBead'}
      };
    },
    methods: function () {
      return {
        'HideComboPopupOnMouseDownBead': { type: '', declaredBy: 'org.apache.royale.html.beads.HideComboPopupOnMouseDownBead'}
      };
    }
  };
};