void InventoryWindow::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); if (!textPopup) return; const Widget *const src = event.getSource(); if (!src) { textPopup->hide(); return; } const int x = event.getX(); const int y = event.getY(); const Rect &rect = mDimension; if (src == mSlotsBar || src == mWeightBar) { // TRANSLATORS: money label textPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"), Units::formatCurrency(PlayerInfo::getAttribute( Attributes::MONEY)).c_str())); } else { const Button *const btn = dynamic_cast<const Button *const>(src); if (!btn) { textPopup->hide(); return; } const std::string text = btn->getDescription(); if (!text.empty()) textPopup->show(x + rect.x, y + rect.y, text); } }
void TabbedArea::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.isConsumed()) { return; } if (mouseEvent.getButton() == MouseEvent::LEFT) { Widget* widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); Tab* tab = dynamic_cast<Tab*>(widget); if (tab != NULL) { setSelectedTab(tab); } } // Request focus only if the source of the event // is not focusble. If the source of the event // is focused we don't want to steal the focus. if (!mouseEvent.getSource()->isFocusable()) { requestFocus(); } }
void DropDown::mouseWheelMovedDown(MouseEvent& mouseEvent) { if (isFocused() && mouseEvent.getSource() == this) { mouseEvent.consume(); mListBox->setSelected(mListBox->getSelected() + 1); } }
void ServerDialog::mouseClicked(MouseEvent &event) { if (event.getButton() == MouseButton::LEFT) { event.consume(); if (event.getClickCount() == 2 && event.getSource() == mServersList) { action(ActionEvent(mConnectButton, mConnectButton->getActionEventId())); } } }
void DropDown::mousePressed(MouseEvent& mouseEvent) { // If we have a mouse press on the widget. if (0 <= mouseEvent.getY() && mouseEvent.getY() < getHeight() && mouseEvent.getX() >= 0 && mouseEvent.getX() < getWidth() && mouseEvent.getButton() == MouseEvent::LEFT && !mDroppedDown && mouseEvent.getSource() == this) { mPushed = true; dropDown(); requestModalMouseInputFocus(); } // Fold up the listbox if the upper part is clicked after fold down else if (0 <= mouseEvent.getY() && mouseEvent.getY() < mFoldedUpHeight && mouseEvent.getX() >= 0 && mouseEvent.getX() < getWidth() && mouseEvent.getButton() == MouseEvent::LEFT && mDroppedDown && mouseEvent.getSource() == this) { mPushed = false; foldUp(); releaseModalMouseInputFocus(); } // If we have a mouse press outside the widget else if (0 > mouseEvent.getY() || mouseEvent.getY() >= getHeight() || mouseEvent.getX() < 0 || mouseEvent.getX() >= getWidth()) { mPushed = false; foldUp(); } }
void Window::mouseDragged(MouseEvent& mouseEvent) { if (mouseEvent.isConsumed() || mouseEvent.getSource() != this) { return; } if (isMovable() && mMoved) { setPosition(mouseEvent.getX() - mDragOffsetX + getX(), mouseEvent.getY() - mDragOffsetY + getY()); } mouseEvent.consume(); }
void Window::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) { return; } if (getParent() != NULL) { getParent()->moveToTop(this); } mDragOffsetX = mouseEvent.getX(); mDragOffsetY = mouseEvent.getY(); mMoved = mouseEvent.getY() <= (int)mTitleBarHeight; }
void PopupList::mouseReleased(MouseEvent& event) { if (mPressedIndex != mListBox->getSelectionByMouse( event.getY() + mPadding)) { mPressedIndex = -2; return; } mPressedIndex = -2; if (event.getSource() == mScrollArea) return; if (mDropDown) mDropDown->updateSelection(); setVisible(false); if (mModal) releaseModalFocus(); }