Handles changes to the selected item.
@param selectedItem
@param previousSelectedItem
338778
function selectedItemChange(selectedItem, previousSelectedItem) {
      if (selectedItem) {
        if (self.displayProperty1) {
          self.searchText = selectedItem[self.displayProperty1];
        }
        if (self.parentForm && self.parentForm !== null) {
          self.parentForm.$setDirty();
        }
      }
      else if (previousSelectedItem && self.searchText) {
        if (previousSelectedItem[self.displayProperty1] === self.searchText) {
          self.searchText = '';
        }
      }

      if (selectedItem !== previousSelectedItem) announceItemChange();
    }
1153422
def on_selection_changed(self):
        
        d = self.declaration
        selection = self.scene.selectedItems()
        self._guards |= 0x01
        try:
            d.selected_items = [item.ref().declaration for item in selection
                                if item.ref()]
        finally:
            self._guards &= ~0x01
314919
function (args) {
            if (this._updatesStopped()) {
                return;
            }
            var dataName = args.dataName;
            if (dataName == "selected") {
                var item = args.dataHolder;
                if ((args.newValue && !args.oldValue) // item was just selected
                        || (!args.newValue && args.oldValue) // item was just unselected
                ) {
                    this._selectionChanged(item.index);
                }
            } else if (dataName == "initiallyDisabled") {
                this._updateCurrentlyDisabled([args.dataHolder]);
            }
        }
500000
function(item) {
        var id = item.id || item;

        var removedItem;
        var index = Selectivity.findIndexById(this._data, id);
        if (index > -1) {
            removedItem = this._data[index];
            this._data.splice(index, 1);
        }

        if (this._value[index] !== id) {
            index = this._value.indexOf(id);
        }
        if (index > -1) {
            this._value.splice(index, 1);
        }

        if (removedItem) {
            this.triggerChange({ removed: removedItem });
        }

        if (id === this._highlightedItemId) {
            this._highlightedItemId = null;
        }

        this._updateInputWidth();
    }
696621
private void setItems(@NonNull List<IDrawerItem> drawerItems, boolean switchedItems) {
        //if we are currently at a switched list set the new reference
        if (originalDrawerItems != null && !switchedItems) {
            originalDrawerItems = drawerItems;
        }
        mDrawerBuilder.getItemAdapter().setNewList(drawerItems);
    }
650602
void onItemsChanged(boolean structureChanged) {
        if (!mPreventDispatchingItemsChanged) {
            if (structureChanged) {
                mIsVisibleItemsStale = true;
                mIsActionItemsStale = true;
            }

            dispatchPresenterUpdate(structureChanged);
        } else {
            mItemsChangedWhileDispatchPrevented = true;
        }
    }
858922
public void onItemClick() {
        if (selected) {
            selected = false;
            getView().reset();

            if (onResetCommand != null) {
                onResetCommand.execute();
            }
        }
        else {
            selected = true;
            getView().select();

            if (onSelectCommand != null) {
                onSelectCommand.execute();
            }
        }
    }
1242248
function trackSelectedItem(element) {

  const items = element.items;
  const itemCount = items ? items.length : 0;

  const previousSelectedItem = element.selectedItem;
  if (!previousSelectedItem) {
    // No item was previously selected.
    if (element.selectionRequired) {
      // Select the first item by default.
      element.selectedIndex = 0;
    }
  } else if (itemCount === 0) {
    // We've lost the selection, and there's nothing left to select.
    element.selectedItem = null;
  } else {
    // Try to find the previously-selected item in the current set of items.
    const indexInCurrentItems = Array.prototype.indexOf.call(items, previousSelectedItem);
    const previousSelectedIndex = element.selectedIndex;
    if (indexInCurrentItems < 0) {
      // Previously-selected item was removed from the items.
      // Select the item at the same index (if it exists) or as close as possible.
      const newSelectedIndex = Math.min(previousSelectedIndex, itemCount - 1);
      // Select by item, since index may be the same, and we want to raise the
      // selected-item-changed event.
      element.selectedItem = items[newSelectedIndex];
    } else if (indexInCurrentItems !== previousSelectedIndex) {
      // Previously-selected item still there, but changed position.
      element.selectedIndex = indexInCurrentItems;
    }
  }
}
190409
@Override
    public void onSelectionChanged(FloatingLabelItemChooser<Product> source, Product selectedItem) {
        Toast.makeText(getActivity(), source.getItemPrinter().print(selectedItem), Toast.LENGTH_SHORT).show();
    }
980823
function(event) {
        event = event || {};

        if (event.added) {
            this._renderSelectedItem(event.added);

            this._scrollToBottom();
        } else if (event.removed) {
            removeElement(this.$(getItemSelector(SELECTED_ITEM_SELECTOR, event.removed.id)));
        } else {
            this._forEachSelectedItem(removeElement);

            this._data.forEach(this._renderSelectedItem, this);

            this._updateInputWidth();
        }

        if (event.added || event.removed) {
            if (this.dropdown) {
                this.dropdown.showResults(this.filterResults(this.dropdown.results), {
                    hasMore: this.dropdown.hasMore
                });
            }

            if (!hasTouch) {
                this.focus();
            }
        }

        this.positionDropdown();

        this._updatePlaceholder();
    }
274478
public void selectTemporary(TwinTextItem item) {
        // if we just want to clear the selection:
        if(item == null) {
            setSelection(getLastItemPosition());
            // the call is passed on to the adapter in setSelection.
            return;
        }
        PickerSpinnerAdapter adapter = (PickerSpinnerAdapter) getAdapter();
        // pass on the call to the adapter (just stores the item):
        adapter.selectTemporary(item);
        final int tempItemPosition = adapter.getCount();
        if(getSelectedItemPosition() == tempItemPosition) {
            // this is quite a hack, first reset the position to 0 but intercept the callback,
            // then redo the selection:
            setSelectionQuietly(0);
        }
        super.setSelection(tempItemPosition);
        // during initialization the system might check our selected position and reset it,
        // thus we need to check after the message queue has been settled
        if (!restoreTemporarySelection) {
            restoreTemporarySelection = true;
            post(new Runnable() {
                @Override
                public void run() {
                    if (restoreTemporarySelection) {
                        restoreTemporarySelection = false;
                        reselectTemporaryItem = false;
                        final int tempItemPosition = getAdapter().getCount();
                        if (getSelectedItemPosition() != tempItemPosition)
                            superSetSelection(tempItemPosition);
                    }
                }
            });
        }
    }
38474
private void onNavDrawerItemClicked(final int itemId) {
        if (itemId == mSelectedItem) {
            mDrawerLayout.closeDrawer(GravityCompat.START);
            return;
        }

        if (isSpecialItem(itemId)) {
            goToNavDrawerItem(itemId);
        } else {
            // launch the target Activity after a short delay, to allow the close animation to play
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    goToNavDrawerItem(itemId);
                }
            }, mConfig.getLaunchDelay());

            // change the active item on the list so the user can see the item changed
            setSelectedNavDrawerItem(itemId);

            // fade out the main content
//            if (mMainContent != null && mConfig.getFadeOutDuration() != -1) {
//                mMainContent.animate().alpha(0).setDuration(mConfig.getFadeOutDuration());
//            }
        }

        mDrawerLayout.closeDrawer(GravityCompat.START);
    }
511416
public void displaySelection(final WComponent selectedComponent) {
		WComponent currentComponent = getCurrentComponent();

		if (selectedComponent == currentComponent) {
			// We are already displaying this component, so nothing to do.
			return;
		}

		// We have a new selection so display it.
		container.removeAll();
		container.add(selectedComponent);
	}
483898
protected void updateSelection (int selidx)
    {
        // do nothing if this element is already selected
        if (selidx == _selectedIndex) {
            return;
        }

        // unhighlight the old component
        if (_selectedIndex != -1) {
            JLabel but = (JLabel)getComponent(_selectedIndex);
            but.setBorder(DESELECTED_BORDER);
        }

        // save the new selection
        _selectedIndex = selidx;

        // if the selection is valid, highlight the new component
        if (_selectedIndex != -1) {
            JLabel but = (JLabel)getComponent(_selectedIndex);
            but.setBorder(SELECTED_BORDER);
        }

        // fire an action performed to let listeners know about our
        // changed selection
        fireActionPerformed();

        repaint();
    }
147058
def toggleSelectedItemState(self, state):
        
        items = self.selectedItems()
        for item in items:
            if ( item.hasRecordState(state) ):
                item.removeRecordState(state)
            else:
                item.addRecordState(state)
88018
public boolean onItemClick(IDrawerItem selectedDrawerItem) {
        //We only need to clear if the new item is selectable
        if (selectedDrawerItem.isSelectable()) {
            //crossfade if we are cross faded
            if (mCrossFader != null) {
                if (mCrossFader.isCrossfaded()) {
                    mCrossFader.crossfade();
                }
            }
            //update everything
            setSelection(selectedDrawerItem.getIdentifier());

            return false;
        } else {
            return true;
        }
    }
900012
function (newItems) {
            var res = this._mergeItemsAndSelectionInfo(newItems, this.getSelectedValues());
            this._setItems(res.items);
            this.json.setValue(this._data, "selectedIndex", res.selectedIndex);
            this.json.setValue(this._data, "selectedCount", res.selectedCount);
        }