Ruler: Fix context menu for items on the ruler
authorSoeren Apel <soeren@apelpie.net>
Sun, 28 Oct 2018 22:26:25 +0000 (23:26 +0100)
committerSoeren Apel <soeren@apelpie.net>
Sun, 28 Oct 2018 22:26:25 +0000 (23:26 +0100)
pv/views/trace/marginwidget.cpp
pv/views/trace/ruler.cpp

index f0d50c9..86ec069 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 6e74ddd..acea8a3 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());
 }