/// <summary> /// Overrides {@link goog.ui.Control#setContentInternal} by also updating the /// grid size and the selection model. Considered protected. /// </summary> /// <param name="content">Array of DOM nodes to be displayed /// as items in the palette grid (one item per cell).</param> public override void setContentInternal(goog.ui.ControlContent content) { var items = content.As <JsArray <Node> >(); base.setContentInternal(new ControlContent(items)); // Adjust the palette size. this.adjustSize_(); // Add the items to the selection model, replacing previous items (if any). if (this.selectionModel_ != null) { // We already have a selection model; just replace the items. this.selectionModel_.clear(); this.selectionModel_.addItems(items); } else { // Create a selection model, initialize the items, and hook up handlers. this.selectionModel_ = new goog.ui.SelectionModel(items); this.selectionModel_.setSelectionHandler(new Action <Node, bool>(this.selectItem_)); this.getHandler().listen( this.selectionModel_, goog.events.EventType.SELECT, new Action <events.Event>(this.handleSelectionChange)); } // In all cases, clear the highlight. this.highlightedIndex_ = -1; }
// goog.ui.Component / goog.ui.Control implementation. public override void disposeInternal() { base.disposeInternal(); if (this.selectionModel_ != null) { this.selectionModel_.dispose(); this.selectionModel_ = null; } this.size_ = null; this.currentCellControl_.dispose(); }