void CmdBox::keyPressEvent(QKeyEvent *event){ bool arrowPressed = false; switch(event->key()){ case Qt::Key_Down: if(event->modifiers() & Qt::ALT){ }else{ changeSelectedItem(1); arrowPressed = true; } break; case Qt::Key_Up: changeSelectedItem(-1); arrowPressed = true; break; default: QDialog::keyPressEvent(event); break; } if(arrowPressed){ if(getSelectedItem() < 0){ setSelectedItem(getItemCount()); }else{ setSelectedItem(getSelectedItem() % (getItemCount()+1)); } getItem(getSelectedItem())->setSelected(true); } return QDialog::keyPressEvent(event); }
void TimelineRenderer::clearData() { Q_D(TimelineRenderer); d->resetCurrentSelection(); setSelectedItem(-1); setSelectionLocked(true); }
void PopupMenuJava::show(const IntRect& r, FrameView* frameView, int index) { JNIEnv* env = WebCore_GetJavaEnv(); ASSERT(frameView->frame()->page()); createPopupMenuJava(frameView->frame()->page()); populate(); setSelectedItem(m_popup, index); // r is in contents coordinates, while popup menu expects window coordinates IntRect wr = frameView->contentsToWindow(r); static jmethodID mid = env->GetMethodID( getJPopupMenuClass(), "fwkShow", "(Lcom/sun/webkit/WebPage;III)V"); ASSERT(mid); env->CallVoidMethod( m_popup, mid, (jobject) WebPage::jobjectFromPage(frameView->frame()->page()), wr.x(), wr.y() + wr.height(), wr.width()); CheckAndClearException(env); }
//---------------------------------------------------------------------- void FMenuList::selectFirstItem() { std::vector<FMenuItem*>::const_iterator iter, end; iter = item_list.begin(); end = item_list.end(); if ( item_list.empty() ) return; if ( hasSelectedItem() ) unselectItem(); while ( iter != end ) { if ( (*iter)->isEnabled() && ! (*iter)->isSeparator() ) { // select first enabled item (*iter)->setSelected(); setSelectedItem(*iter); break; } ++iter; } }
//---------------------------------------------------------------------- void FMenuList::unselectItem() { if ( hasSelectedItem() ) getSelectedItem()->unsetSelected(); setSelectedItem(0); }
void PopupMenuJava::updateFromElement() { client()->setTextFromItem(client()->selectedIndex()); if (!m_popup) { return; } setSelectedItem(m_popup, client()->selectedIndex()); }
void MSOptionMenu::selectedItem(int item_) { if (item_!=selectedItem()) { setSelectedItem(item_); drawFieldValue(); } }
bool ListBox::setSelectedItemByText(const std::string& text) { ListBoxItemVector::iterator item = m_Items.begin(); for(;item != m_Items.end();++item) { if(text == (*item)->getText()) { setSelectedItem(item->get()); return true; } } return false; }
void Popup::setSelectedID(ItemID newItemID) { for (auto i : m_menu->items()) { if (i->id() == newItemID) { setSelectedItem(*i); break; } } }
int AquariaComboBox::addItem(const std::string &n) { items.push_back(n); if (items.size() == 1) { setSelectedItem(0); } return items.size()-1; }
void Container::setSelectedItem(QTreeWidget *treeView, ListComponent *c) { if(treeView->topLevelItemCount()) { QTreeWidgetItem *treeItem=treeView->topLevelItem(0); if(!setSelectedItem(treeItem,c)) { treeView->setItemSelected(treeItem,0); } } }
void UINumberPicker::relocateContainer(bool value) { //重定位子组件位置坐标 switch (_pickerDirection) { case PickerDirection::VERTICAL: { PickerCell *cell = itemForPoint( Point(0,getContentSize().height/2)); setSelectedItem(cell); break; } case PickerDirection::HORIZONTAL: { PickerCell *cell = itemForPoint( Point(getContentSize().width/2,0) ); setSelectedItem(cell); break; } default: break; } }
bool AquariaComboBox::setSelectedItem(const std::string &item) { for (int i = 0; i < items.size(); i++) { if (items[i] == item) { setSelectedItem(i); return true; } } return false; }
void UINumberPicker::onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event) { do { CC_BREAK_IF(!isVisible()); if (containsTouchObject(m_pTouches, touch)) { if (m_pTouches.size() == 1 && m_bTouchMoved) { //手指放开,自由移动 schedule(schedule_selector(UINumberPicker::deaccelerateScrolling)); } if (m_pTouches.size() == 1 && !m_bTouchMoved) { //判断当前时一个单击行为,获取当前点击的是哪一个Item; PickerCell *cell = itemForPoint(m_tTouchPoint); setSelectedItem(cell); } std::vector<Touch*>::iterator ite = m_pTouches.begin(); while (ite != m_pTouches.end()) { Touch *ptouch =*ite; if (ptouch->getID() == touch->getID()) { m_pTouches.erase(ite); break; } ite++; } } if (m_pTouches.size() == 0) { m_bDragging = false; m_bTouchMoved = false; } m_bIsScrolling = true; } while (0); }
void UINumberPicker::refreshValue(int value) { if (value > m_maxValue || value < m_minValue) { value = m_minValue; } bool hasfind = false; for (size_t i = 0; i < sortChildrenArray.size(); i++) { PickerCell * cell = sortChildrenArray[i]; if (cell->getCellValue() == value) { setSelectedItem(cell); hasfind = true; break; } } if (!hasfind) { show_value = value; invalidateDisplayList(); } }
AquariaComboBox::AquariaComboBox() : RenderObject() { //Quad *bar, *window, *scrollBtnUp, *scrollBtnDown, *scrollBar; bar = new Quad("gui/combo-drop", Vector(0,0)); addChild(bar, PM_POINTER); scrollBtnUp = new Quad("gui/combo-button-up", Vector(70,0)); scrollBtnUp->alpha = 0; scrollBtnUp->flipVertical(); addChild(scrollBtnUp, PM_POINTER); scrollBtnDown = new Quad("gui/combo-button-up", Vector(88,0)); scrollBtnDown->alpha = 0; addChild(scrollBtnDown, PM_POINTER); selectedItemLabel = new BitmapText(&dsq->smallFont); selectedItemLabel->setAlign(ALIGN_LEFT); selectedItemLabel->setFontSize(8); selectedItemLabel->offset.y = -10; selectedItemLabel->position.x = -50; addChild(selectedItemLabel, PM_POINTER); numDrops = 8; mb = false; isopen = false; setSelectedItem(0); scroll = 0; enqueuedSelectItem = -1; scrollDelay = 0; firstScroll = 0; }
void TimelineRenderer::selectPrevFromSelectionId(int selectionId) { Q_D(TimelineRenderer); setSelectedItem(d->model->prevItemBySelectionId(selectionId, d->zoomer->rangeStart(), d->selectedItem)); }
void AquariaComboBox::onUpdate(float dt) { RenderObject::onUpdate(dt); if (alpha.x < 1) return; //window->alpha.interpolateTo(1, 0.2); if (enqueuedSelectItem != -1) { setSelectedItem(enqueuedSelectItem); enqueuedSelectItem = -1; } scrollDelay -= dt; if (scrollDelay < 0) scrollDelay = 0; if (isopen) { if (!core->mouse.buttons.left) { firstScroll = 1; scrollDelay = 0; } if (core->mouse.buttons.left && scrollBtnDown->isCoordinateInsideWorldRect(core->mouse.position, 20, 32)) { if (scrollDelay == 0) { doScroll(1); if (firstScroll) { scrollDelay = SCROLL_DELAY_FIRST; firstScroll = 0; } else { scrollDelay = SCROLL_DELAY; } } scrollBtnDown->setTexture("gui/combo-button-down"); } else { scrollBtnDown->setTexture("gui/combo-button-up"); } if (core->mouse.buttons.left && scrollBtnUp->isCoordinateInsideWorldRect(core->mouse.position, 20, 32)) { if (scrollDelay == 0) { doScroll(0); if (firstScroll) { scrollDelay = SCROLL_DELAY_FIRST; firstScroll = 0; } else { scrollDelay = SCROLL_DELAY; } } scrollBtnUp->setTexture("gui/combo-button-down"); } else { scrollBtnUp->setTexture("gui/combo-button-up"); } } if (bar->isCoordinateInsideWorld(core->mouse.position)) { if (!mb && core->mouse.buttons.left) { mb = true; } else if (mb && !core->mouse.buttons.left) { mb = false; core->sound->playSfx("click"); if (isopen) close(); else open(); } } else { mb = false; } if (isopen) { if (core->mouse.scrollWheelChange > 0) { doScroll(0); } else if (core->mouse.scrollWheelChange < 0) { doScroll(1); } } }
void MailListView::setSelectedRow(int row) { if (QTableWidgetItem* rowItem = item(row, 0)) setSelectedItem(rowItem); }
void MailListView::setSelectedId(const QMailId& id) { if (EmailListItem* item = getRef(id)) setSelectedItem(item); }
void UINumberPicker::setValue(int value) { if (value > m_maxValue || value < m_minValue) { value = m_minValue; } bool hasfind = false; for (size_t i = 0; i < sortChildrenArray.size(); i++) { PickerCell * cell = sortChildrenArray[i]; if (cell->getCellValue() == value) { setSelectedItem(cell); hasfind = true; break; } } if (!hasfind) { refreshValue(value); return; } if (!hasfind) { int currentValue = getValue(); int delta = value - currentValue; if ( abs(delta) > (int)(m_maxValue - m_minValue)/2 ) { int deltaCurrent = MIN(m_maxValue - currentValue, currentValue - m_minValue); int deltaValue = MIN(m_maxValue - value, value - m_minValue); delta = -(deltaCurrent + deltaValue); } switch (_pickerDirection) { case PickerDirection::VERTICAL: { clickMoveDisy = delta * item_height; if (clickMoveDisy > 0) { scrollUniformSpeed = -4; } else { scrollUniformSpeed = 4; } if (fabsf(clickMoveDisy) > SCROLL_DEACCEL_DIST) { //璁$畻寰楀嚭璇tem璺濈涓績鐨勫瀭鐩村亸绉� this->schedule(schedule_selector(UINumberPicker::clickDeaccelerateScrolling)); } break; } case PickerDirection::HORIZONTAL: { clickMoveDisx = delta * item_width; if (clickMoveDisx > 0) { scrollUniformSpeed = -20; } else { scrollUniformSpeed = 20; } if (fabsf(clickMoveDisx) > SCROLL_DEACCEL_DIST) { //璁$畻寰楀嚭璇tem璺濈涓績鐨勫瀭鐩村亸绉� this->schedule(schedule_selector(UINumberPicker::clickDeaccelerateScrolling)); } break; } default: break; } } m_bIsScrolling = true; }