void OperationDiagramView::graphButtonReleaseEvent(const GdkEventButton *event) { if(event->button == 1) { const OperationClass *node = gOperationDiagramView->getDiagram().getNode( gStartPosInfo.x, gStartPosInfo.y); if(node) { /* DiagramPoint offset = gStartPosInfo.startPos; offset.sub(node->getPosition()); DiagramPoint newPos = DiagramPoint(event->x, event->y); newPos.sub(offset); node->setPosition(newPos); gOperationDiagram->getOpGraph().drawDiagram(); */ } } else { displayContextMenu(event->button, event->time, (gpointer)event); } }
void ComponentDiagramView::buttonReleaseEvent(const GdkEventButton *event) { if(event->button == 1) { ComponentNode *node = mComponentDiagram.getNode( gStartPosInfo.x, gStartPosInfo.y); if(node) { GraphPoint offset = gStartPosInfo; offset.sub(node->getRect().start); GraphPoint newPos = GraphPoint(static_cast<int>(event->x), static_cast<int>(event->y)); newPos.sub(offset); node->setPos(newPos); mComponentDiagram.setModified(); drawToDrawingArea(); } } else { displayContextMenu(event->button, event->time, (gpointer)event); } }
extern "C" G_MODULE_EXPORT gboolean on_EditFiles_button_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { bool handled = false; GdkEventButton *eventBut = reinterpret_cast<GdkEventButton*>(event); if(eventBut->button == 3) // Right button { displayContextMenu(eventBut->button, eventBut->time, (gpointer)event); handled = true; } return handled; }
CCardLabel::CCardLabel(QWidget *parent, bool isVirtualCard) : QLabel(parent) , mCards(CCardTable::getCardTable()) , mTitleIcon() , mLastLeftClickPos(0) , mLockButton(0) , mIsVirtual(isVirtualCard) { CCardLabelNexus::getCardLabelNexus().registerCardLabel(this); setScaledContents(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayContextMenu(QPoint))); }
INT_PTR onContextMenu (HWND hDlg, WPARAM wParam, LPARAM lParam) { DWORD x = LOWORD (lParam); DWORD y = HIWORD (lParam); RECT rc; // client area of window POINT pt = {x, y}; // location of mouse click // Get the bounding rectangle of the client area. GetClientRect(hDlg, &rc); // Convert the mouse position to client coordinates. ScreenToClient (hDlg, &pt); // If the position is in the client area, display a shortcut menu. if (PtInRect (&rc, pt)) { ClientToScreen (hDlg, &pt); displayContextMenu (hDlg, pt); return TRUE; } // Return FALSE if no menu is displayed. return FALSE; }