void PeerListContent::removeRow(not_null<PeerListRow*> row) { auto index = row->absoluteIndex(); auto isSearchResult = row->isSearchResult(); auto &eraseFrom = isSearchResult ? _searchRows : _rows; Assert(index >= 0 && index < eraseFrom.size()); Assert(eraseFrom[index].get() == row); auto pressedData = saveSelectedData(_pressed); auto contextedData = saveSelectedData(_contexted); setSelected(Selected()); setPressed(Selected()); setContexted(Selected()); _rowsById.erase(row->id()); auto &byPeer = _rowsByPeer[row->peer()]; byPeer.erase(ranges::remove(byPeer, row), end(byPeer)); removeFromSearchIndex(row); _filterResults.erase( ranges::remove(_filterResults, row), end(_filterResults)); removeRowAtIndex(eraseFrom, index); restoreSelection(); setPressed(restoreSelectedData(pressedData)); setContexted(restoreSelectedData(contextedData)); }
/*! Handles the given gesture event. \param event The event to handle. */ void NmAttachmentListItem::gestureEvent(QGestureEvent *event) { NM_FUNCTION; if (HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) { switch (tap->tapStyleHint()) { case HbTapGesture::Tap: { Qt::GestureState state = tap->state(); HbInstantFeedback::play(HbFeedback::Basic); setPressed(true); if (state == Qt::GestureFinished) { emit itemActivated(); setPressed(false); } else if (state == Qt::GestureCanceled) { setPressed(false); } break; } case HbTapGesture::TapAndHold: { emit itemLongPressed(event->mapToGraphicsScene(tap->position())); setPressed(false); break; } } // switch } else { // Let the HbWidget handle the event. HbWidget::gestureEvent(event); } }
bool Button::collide(float x_screen, float y_screen) { //need to figure out the screen pos of the button corner and its width and heigh in pixels /* float posx = parent->getPosX(); float posy = parent->getPosY(); float width = parent->getWidth() * this->getRelWidth(); float height = parent->getHeight() * this->getRelHeight(); float rposx = posx + getRelX(); float rposy = posy + getRelY();*/ setPositions(); float rposx = getPosX(); float rposy = getPosY(); float width = getWidth(); float height = getHeight(); if ( (x_screen < rposx + width) && (rposx <= x_screen ) && (y_screen < rposy + height) && (rposy <= y_screen ) ) { setPressed(true); return true; } else { setPressed(false); return false; } }
bool Clickable::onEvent(const sf::Event &e) { //Update the focusable widget. bool block = Focusable::onEvent(e); if(!block) { if(isFocused()) { if(e.type == sf::Event::KeyPressed) { if(e.key.code == sf::Keyboard::Return) { block = true; m_relPos = sf::Vector2f(0, 0); setPressed(true); } } if(e.type == sf::Event::KeyReleased) { if(e.key.code == sf::Keyboard::Return) { block = true; m_relPos = sf::Vector2f(0, 0); setPressed(false); } } } if(e.type == sf::Event::MouseButtonPressed) { if(e.mouseButton.button == sf::Mouse::Left) { if(m_boundingBox.contains(e.mouseButton.x, e.mouseButton.y)) { block = true; m_relPos = sf::Vector2f(e.mouseButton.x, e.mouseButton.y) - sf::Vector2f(m_boundingBox.left, m_boundingBox.top); setPressed(true); } } } if(e.type == sf::Event::MouseButtonReleased) { if(e.mouseButton.button == sf::Mouse::Left) { if(m_boundingBox.contains(e.mouseButton.x, e.mouseButton.y) || m_pressed) { block = true; m_relPos = sf::Vector2f(e.mouseButton.x, e.mouseButton.y) - sf::Vector2f(m_boundingBox.left, m_boundingBox.top); setPressed(false); } } } } return block; }
bool UIWidget::propagateOnMouseRelease(const Point& mousePos, Fw::MouseButton button) { // do a backup of children list, because it may change while looping it UIWidgetList children; for(const UIWidgetPtr& child : m_children) { // events on hidden or disabled widgets are discarded if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible()) continue; // mouse release events go to all children children.push_back(child); } for(const UIWidgetPtr& child : children) { if(child->propagateOnMouseRelease(mousePos, button)) return true; } bool ret = onMouseRelease(mousePos, button); if(isPressed() && button == Fw::MouseLeftButton) setPressed(false); return ret; }
void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event) { Q_D(QQuickMouseArea); d->stealMouse = false; if (!d->enabled && !d->pressed) { QQuickItem::mouseReleaseEvent(event); } else { d->saveEvent(event); setPressed(event->button(), false); if (!d->pressed) { // no other buttons are pressed #ifndef QT_NO_DRAGANDDROP if (d->drag) d->drag->setActive(false); #endif // If we don't accept hover, we need to reset containsMouse. if (!acceptHoverEvents()) setHovered(false); QQuickWindow *w = window(); if (w && w->mouseGrabberItem() == this) ungrabMouse(); setKeepMouseGrab(false); } } d->doubleClick = false; }
void CalendarBox::Inner::mouseReleaseEvent(QMouseEvent *e) { auto pressed = _pressed; setPressed(kEmptySelection); if (pressed != kEmptySelection && pressed == _selected) { _dateChosenCallback(_context->dateFromIndex(pressed)); } }
void UIButtonBase::keyUp(int key) { if (key == VK_SPACE || key == VK_RETURN) { setPressed(false); } }
void MembersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { auto pressed = _pressed; auto kickPressed = _kickPressed; setPressed(-1); if (e->button() == Qt::LeftButton) { if (pressed == _selected && kickPressed == _kickSelected) { if (kickPressed >= 0) { if (!_kickRequestId) { _kickConfirm = _rows.at(_kickSelected); if (_kickBox) _kickBox->deleteLater(); auto text = (_filter == MembersFilter::Recent ? (_channel->isMegagroup() ? lng_profile_sure_kick : lng_profile_sure_kick_channel) : lng_profile_sure_kick_admin)(lt_user, _kickConfirm->firstName); _kickBox = Ui::show(Box<ConfirmBox>(text, base::lambda_guarded(this, [this] { if (_filter == MembersFilter::Recent) { _kickRequestId = MTP::send(MTPchannels_KickFromChannel(_channel->inputChannel, _kickConfirm->inputUser, MTP_bool(true)), rpcDone(&Inner::kickDone), rpcFail(&Inner::kickFail)); } else { _kickRequestId = MTP::send(MTPchannels_EditAdmin(_channel->inputChannel, _kickConfirm->inputUser, MTP_channelRoleEmpty()), rpcDone(&Inner::kickAdminDone), rpcFail(&Inner::kickFail)); } })), KeepOtherLayers); } } else if (pressed >= 0) { chooseParticipant(); } } } }
void QDeclarative1MouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarative1MouseArea); d->moved = false; d->stealMouse = d->preventStealing; if (!d->absorb) QDeclarativeItem::mousePressEvent(event); else { d->longPress = false; d->saveEvent(event); if (d->drag) { d->dragX = drag()->axis() & QDeclarative1Drag::XAxis; d->dragY = drag()->axis() & QDeclarative1Drag::YAxis; } if (d->drag) d->drag->setActive(false); setHovered(true); d->startScene = event->scenePos(); // we should only start timer if pressAndHold is connected to. if (d->isPressAndHoldConnected()) d->pressAndHoldTimer.start(PressAndHoldDelay, this); setKeepMouseGrab(d->stealMouse); event->setAccepted(setPressed(true)); } }
void ButtonActor::Collide(const CollFlags& collFlags) { if(m_collFlags.wall) { setPressed(true); } CollidingActor::Collide(collFlags); }
void Test::testSecondSet() { myDialog->myComboBox->setCurrentIndex(1); myDialog->mySetLineEdit->setText("1000"); QSignalSpy signalSpy(myDialog, SIGNAL(setPressed())); QTest::mouseClick(myDialog->mySetButton, Qt::LeftButton); QCOMPARE(1, signalSpy.count()); }
void MembersBox::Inner::mousePressEvent(QMouseEvent *e) { _mouseSelection = true; _lastMousePos = e->globalPos(); updateSelection(); setPressed(_selected); _kickPressed = _kickSelected; if (_selected >= 0 && _selected < _datas.size() && _kickSelected < 0) { addRipple(_datas[_selected]); } }
ButtonActor::ButtonActor(const String& spritePath, const Bitmask * const mask, const Vector2& position, const Vector2& size, float timer) : CollidingActor(mask, size) , m_path(spritePath) , m_time(timer) { setPressed(false); SetLayered(false); SetPosition(position); }
// onMousePressed bool UIButtonBase::onMouseDown(const Point2& pos, int button) { if (button == 0) { setPressed(true); return true; } return false; }
void ButtonActor::Update(float dt){ if(m_time>0 && m_pressed==true) { m_countup+= dt; //std::cout<<m_countup<<std::endl; if(m_countup>=m_time) setPressed(false); } CollidingActor::Update(dt); }
void Button::onEvent(const sf::Event& event) { if(isDisabled()) return; if(event.type == sf::Event::MouseButtonPressed) { setPressed(isHover()); if(isHover() && m_callbackPressed) m_callbackPressed(); } if(event.type == sf::Event::MouseButtonReleased || event.type == sf::Event::MouseLeft) { if(isPressed() && m_callbackReleased) m_callbackReleased(); setPressed(false); } }
/*! \internal */ void QObjectPickerPrivate::releasedEvent(QPickEvent *event) { Q_Q(QObjectPicker); if (m_acceptedLastPressedEvent) { emit q->released(event); setPressed(false); } else { event->setAccepted(false); propagateEvent(event, Released); } }
void MaskedMouseArea::mouseReleaseEvent(QMouseEvent *event) { setPressed(false); emit released(); const int threshold = qApp->styleHints()->startDragDistance(); const bool isClick = (threshold >= qAbs(event->x() - m_pressPoint.x()) && threshold >= qAbs(event->y() - m_pressPoint.y())); if (isClick) emit clicked(); }
void Menu::itemReleased(TriggeredSource source) { if (_pressed >= 0 && _pressed < _actions.size()) { auto pressed = _pressed; setPressed(-1); if (source == TriggeredSource::Mouse && _actionsData[pressed].ripple) { _actionsData[pressed].ripple->lastStop(); } if (pressed == _selected && _triggeredCallback) { _triggeredCallback(_actions[_selected], itemTop(_selected), source); } } }
/*! \internal */ void QObjectPickerPrivate::pressedEvent(QPickEvent *event) { Q_Q(QObjectPicker); emit q->pressed(event); m_acceptedLastPressedEvent = event->isAccepted(); if (!m_acceptedLastPressedEvent) { // Travel parents to transmit the event propagateEvent(event, Pressed); } else { setPressed(true); } }
void QDeclarativeGeoMapMouseArea::releaseEvent(QDeclarativeGeoMapMouseEvent *event) { if (!enabled_) { //TODO QDeclarativeItem::mouseReleaseEvent(convert event to regular event here) return; } // save event setPressed(false, event); pressedButton_ = Qt::NoButton; modifiers_ = Qt::NoModifier; doubleClick_ = false; }
void Button::onUpdate() { if(isDisabled()) return; bool hover = contains(m_application.mapPixelToCoords(static_cast<sf::Vector2i>(m_application.getMousePosition()))); setHover(hover); if(hover && m_callbackHover) m_callbackHover(); if(!sf::Mouse::isButtonPressed(sf::Mouse::Left) && !sf::Mouse::isButtonPressed(sf::Mouse::Right)) setPressed(false); }
void Menu::clearActions() { setSelected(-1); setPressed(-1); _actionsData.clear(); for (auto action : base::take(_actions)) { if (action->parent() == this) { delete action; } } resize(_forceWidth ? _forceWidth : _st.widthMin, _st.skip * 2); if (_resizedCallback) { _resizedCallback(); } }
// onMouseUp bool UIButtonBase::onMouseUp(const Point2 &pos, int button) { if (button == 0) { if (m_bPressed) { setPressed(false); onClick(); } return true; } return false; }
void Button::mouseReleaseEvent(QMouseEvent* ev) { setPressed( false ); if (ev->button() == Qt::LeftButton) { if(__enable_press_hold) m_timer->stop(); else emit clicked(this); } else if (ev->button() == Qt::RightButton) { emit rightClicked(this); } }
void ComboBox::showPopup() { setPressed(true); if(_win) removeWindow(); else { gsize_t pad = Application::getInstance()->getDefaultTheme()->getTextPadding(); gsize_t height = _items.size() * (getGraphics()->getFont().getSize().height + pad * 2); const Window *w = getWindow(); Pos pos(w->getPos().x + getWindowPos().x, w->getPos().y + getWindowPos().y + getSize().height); _win = make_control<ItemWindow>(this,pos,Size(getSize().width,height)); _win->show(); Application::getInstance()->addWindow(_win); } }
void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeMouseArea); if (!d->absorb) { QDeclarativeItem::mouseReleaseEvent(event); } else { d->saveEvent(event); setPressed(false); if (d->drag) d->drag->setActive(false); // If we don't accept hover, we need to reset containsMouse. if (!acceptHoverEvents()) setHovered(false); setKeepMouseGrab(false); } }
void PeerListContent::clearAllContent() { setSelected(Selected()); setPressed(Selected()); setContexted(Selected()); _mouseSelection = false; _lastMousePosition = std::nullopt; _rowsById.clear(); _rowsByPeer.clear(); _filterResults.clear(); _searchIndex.clear(); _rows.clear(); _searchRows.clear(); _searchQuery = _normalizedSearchQuery = _mentionHighlight = QString(); }
void Menu::itemPressed(TriggeredSource source) { if (source == TriggeredSource::Mouse && !_mouseSelection) { return; } if (_selected >= 0 && _selected < _actions.size() && _actions[_selected]->isEnabled()) { setPressed(_selected); if (source == TriggeredSource::Mouse) { if (!_actionsData[_pressed].ripple) { auto mask = RippleAnimation::rectMask(QSize(width(), _itemHeight)); _actionsData[_pressed].ripple = std::make_unique<RippleAnimation>(_st.ripple, std::move(mask), [this, selected = _pressed] { updateItem(selected); }); } _actionsData[_pressed].ripple->add(mapFromGlobal(QCursor::pos()) - QPoint(0, itemTop(_pressed))); } else { itemReleased(source); } } }