remove the canvas context menu

The middle-click context menu (crosshair toggle, copy as PNG/SVG)
duplicated functionality that is now reachable elsewhere: the
crosshair is toggled by its own toolbar button and the PNG/SVG
clipboard copies get dedicated toolbar buttons. Removing it frees the
middle mouse button on the plot canvas.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
markusro committed 2026-10-19 23:16:22 +02:00
1 parent d539a27423
commit 0135504de2
1 file changed
-37
-37
View File
@@ -3270,9 +3270,6 @@ class MonitorWidgets:
# add figure to canvas
self.matplot_canvas = BlitSafeCanvas( self.matplot_figure )
# add ctrl + right-click context menu to canvas
self.matplot_canvas.connect("button-press-event", self.on_canvas_button_press)
self.display_table = self.xml_gui.get_object( "display_table" )
self.display_table.attach( self.matplot_canvas, 0, 6, 0, 1, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, 0, 0 )
self.matplot_canvas.show( )
@@ -3825,40 +3822,6 @@ class MonitorWidgets:
self.matplot_cursor = None
self.matplot_canvas.draw()
def on_canvas_button_press(self, widget, event):
"""Handle button press events on matplotlib canvas"""
if event.button == 2: # middle click
self.show_canvas_context_menu(event)
return True
return False
def show_canvas_context_menu(self, event):
"""Show context menu for matplotlib canvas"""
menu = gtk.Menu()
# toggle cursor
toggle_cursor = gtk.CheckMenuItem(label="Crosshair")
# Set the current state based on whether cursor exists
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
toggle_cursor.set_active(True)
else:
toggle_cursor.set_active(False)
toggle_cursor.connect("toggled", lambda w: self.matplot_cursor_button.set_active(w.get_active()))
menu.append(toggle_cursor)
# Copy as PNG
item_copy_png = gtk.MenuItem(label="Copy as PNG")
item_copy_png.connect("activate", self.copy_canvas_as_png)
menu.append(item_copy_png)
# Copy as SVG
item_copy_svg = gtk.MenuItem(label="Copy as SVG")
item_copy_svg.connect("activate", self.copy_canvas_as_svg)
menu.append(item_copy_svg)
menu.show_all()
menu.popup_at_pointer(event)
def copy_canvas_as_png(self, widget):
"""Copy canvas to clipboard as PNG"""
self.copy_display_data_to_clipboard(widget)