]> sigrok.org Git - pulseview.git/commitdiff
Ruler: Fix context menu for items on the ruler
authorSoeren Apel <redacted>
Sun, 28 Oct 2018 22:26:25 +0000 (23:26 +0100)
committerSoeren Apel <redacted>
Sun, 28 Oct 2018 22:26:25 +0000 (23:26 +0100)
pv/views/trace/marginwidget.cpp
pv/views/trace/ruler.cpp

index f0d50c97b900abf334b4807e6c75ab3c7ac844a9..86ec069bc2370147b76b9cb16bfc606655f2cabf 100644 (file)
@@ -53,13 +53,17 @@ void MarginWidget::show_popup(const shared_ptr<ViewItem> &item)
 
 void MarginWidget::contextMenuEvent(QContextMenuEvent *event)
 {
+       event->setAccepted(false);
+
        const shared_ptr<ViewItem> r = get_mouse_over_item(mouse_point_);
        if (!r)
                return;
 
        QMenu *menu = r->create_header_context_menu(this);
-       if (menu)
+       if (menu) {
+               event->setAccepted(true);
                menu->popup(event->globalPos());
+       }
 }
 
 void MarginWidget::keyPressEvent(QKeyEvent *event)
index 6e74ddd0a29a272b2d1661b64d2054949767f040..acea8a368b457469e44c11e758f95f935a56e68e 100644 (file)
@@ -121,6 +121,12 @@ pv::util::Timestamp Ruler::get_time_from_x_pos(uint32_t x) const
 
 void Ruler::contextMenuEvent(QContextMenuEvent *event)
 {
+       MarginWidget::contextMenuEvent(event);
+
+       // Don't show a context menu if the MarginWidget found a widget that shows one
+       if (event->isAccepted())
+               return;
+
        context_menu_x_pos_ = event->pos().x();
 
        QMenu *const menu = new QMenu(this);
@@ -143,6 +149,7 @@ void Ruler::contextMenuEvent(QContextMenuEvent *event)
        toggle_hover_marker->setText(hover_marker_shown ?
                tr("Disable mouse hover marker") : tr("Enable mouse hover marker"));
 
+       event->setAccepted(true);
        menu->popup(event->globalPos());
 }