// static void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata) { // Note: item is the LLScrollListCtrl LLComboBox *self = (LLComboBox *) userdata; const std::string name = self->mList->getSelectedItemLabel(); S32 cur_id = self->getCurrentIndex(); if (cur_id != -1) { self->setLabel(name); if (self->mAllowTextEntry) { gFocusMgr.setKeyboardFocus(self->mTextEntry); self->mTextEntry->selectAll(); } } // hiding the list reasserts the old value stored in the text editor/dropdown button self->hideList(); // commit does the reverse, asserting the value in the list self->onCommit(); }
// static void LLComboBox::onButtonDown(void *userdata) { LLComboBox *self = (LLComboBox *)userdata; if (!self->mList->getVisible()) { LLScrollListItem* last_selected_item = self->mList->getLastSelectedItem(); if (last_selected_item) { // highlight the original selection before potentially selecting a new item self->mList->highlightNthItem(self->mList->getItemIndex(last_selected_item)); } if( self->mPrearrangeCallback ) { self->mPrearrangeCallback( self, self->mCallbackUserData ); } if (self->mList->getItemCount() != 0) { self->showList(); } self->setFocus( TRUE ); // pass mouse capture on to list if button is depressed if (self->mButton->hasMouseCapture()) { gFocusMgr.setMouseCapture(self->mList); } } else { self->hideList(); } }