Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates
Maybe return True in your eventFilter, so that the event is not processed further by other widgets? Regards, -- Jacky Volpes Ingénieur SIG - Oslandia Le 13/04/2023 à 08:11, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer a écrit : I thought I tried this before and it still showed the menu with its menu grayed out, but maybe I set it on the submenu item, but I solved my issue by calling menu.setDisabled(True) on the QMenu. I reset it to False after my editing is done so the context menu is available again. If anyone thinks of a better way feel free to answer, but this will work for now. I was hoping the setContextMenuPolicy methd would work. -Original Message- From: QGIS-Developer On Behalf Of Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer Sent: Thursday, April 13, 2023 1:29 AM To: Nyall Dawson Cc:qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates I am not using QgsMapTool. T o capute mouse events, I declared my class as class AoiSizeValidator(QWidget): And added def eventFilter(self, source, event): with code that captures mouse click events. I tried using iface.mapCanvas().setContextMenuPolicy(Qt.NoContextMenu) and iface.mapCanvas().setContextMenuPolicy(Qt.PreventContextMenu) But it did not work. I found that suggestion on a site where someone was looking to disable the context menu for QWebEngineView, so thought it would work for the map canvas. I did find half a solution by setting iface.mapCanvas().contextMenuAboutToShow.connect(self.disable_context_menu) def disable_map_canvas_context_menu(self, menu: QMenu, event: QgsMapMouseEvent): menu.clear() which basically completely clears the context menu from all its widgets, but I would like he menu back after my right click event happens to end the edit session. -Original Message- From: Nyall Dawson Sent: Wednesday, April 12, 2023 9:09 PM To: Catania, Luke A ERDC-RDE-GRL-VA CIV Cc:qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates On Thu, 13 Apr 2023 at 10:47, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote: I have an event filter on the map canvas that performs a commit during feature editing when right clicking on the canvas. While this performs the commit, it then pops up Copy Coordinates. I don’t want the user to see this. I want my mouse click event to be recognized and not have QGIS use it to popup the Copy Coordinates. Is there a way to call QgsMapTool.deactivate on that built in tool just for this instance and then reactivate it? Are you using a custom QgsMapTool subclass? If so, implement the "flags" method and don't return the ShowContextMenu flag. Nyall ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates
I thought I tried this before and it still showed the menu with its menu grayed out, but maybe I set it on the submenu item, but I solved my issue by calling menu.setDisabled(True) on the QMenu. I reset it to False after my editing is done so the context menu is available again. If anyone thinks of a better way feel free to answer, but this will work for now. I was hoping the setContextMenuPolicy methd would work. -Original Message- From: QGIS-Developer On Behalf Of Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer Sent: Thursday, April 13, 2023 1:29 AM To: Nyall Dawson Cc: qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates I am not using QgsMapTool. T o capute mouse events, I declared my class as class AoiSizeValidator(QWidget): And added def eventFilter(self, source, event): with code that captures mouse click events. I tried using iface.mapCanvas().setContextMenuPolicy(Qt.NoContextMenu) and iface.mapCanvas().setContextMenuPolicy(Qt.PreventContextMenu) But it did not work. I found that suggestion on a site where someone was looking to disable the context menu for QWebEngineView, so thought it would work for the map canvas. I did find half a solution by setting iface.mapCanvas().contextMenuAboutToShow.connect(self.disable_context_menu) def disable_map_canvas_context_menu(self, menu: QMenu, event: QgsMapMouseEvent): menu.clear() which basically completely clears the context menu from all its widgets, but I would like he menu back after my right click event happens to end the edit session. -Original Message- From: Nyall Dawson Sent: Wednesday, April 12, 2023 9:09 PM To: Catania, Luke A ERDC-RDE-GRL-VA CIV Cc: qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates On Thu, 13 Apr 2023 at 10:47, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote: > > I have an event filter on the map canvas that performs a commit during > feature editing when right clicking on the canvas. While this performs the > commit, it then pops up Copy Coordinates. I don’t want the user to see this. > I want my mouse click event to be recognized and not have QGIS use it to > popup the Copy Coordinates. Is there a way to call QgsMapTool.deactivate on > that built in tool just for this instance and then reactivate it? Are you using a custom QgsMapTool subclass? If so, implement the "flags" method and don't return the ShowContextMenu flag. Nyall > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: > Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked > Unsubscribe: > Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates
I am not using QgsMapTool. T o capute mouse events, I declared my class as class AoiSizeValidator(QWidget): And added def eventFilter(self, source, event): with code that captures mouse click events. I tried using iface.mapCanvas().setContextMenuPolicy(Qt.NoContextMenu) and iface.mapCanvas().setContextMenuPolicy(Qt.PreventContextMenu) But it did not work. I found that suggestion on a site where someone was looking to disable the context menu for QWebEngineView, so thought it would work for the map canvas. I did find half a solution by setting iface.mapCanvas().contextMenuAboutToShow.connect(self.disable_context_menu) def disable_map_canvas_context_menu(self, menu: QMenu, event: QgsMapMouseEvent): menu.clear() which basically completely clears the context menu from all its widgets, but I would like he menu back after my right click event happens to end the edit session. -Original Message- From: Nyall Dawson Sent: Wednesday, April 12, 2023 9:09 PM To: Catania, Luke A ERDC-RDE-GRL-VA CIV Cc: qgis-developer@lists.osgeo.org Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates On Thu, 13 Apr 2023 at 10:47, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote: > > I have an event filter on the map canvas that performs a commit during > feature editing when right clicking on the canvas. While this performs the > commit, it then pops up Copy Coordinates. I don’t want the user to see this. > I want my mouse click event to be recognized and not have QGIS use it to > popup the Copy Coordinates. Is there a way to call QgsMapTool.deactivate on > that built in tool just for this instance and then reactivate it? Are you using a custom QgsMapTool subclass? If so, implement the "flags" method and don't return the ShowContextMenu flag. Nyall > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: > Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked > Unsubscribe: > Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates
On Thu, 13 Apr 2023 at 10:47, Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer wrote: > > I have an event filter on the map canvas that performs a commit during > feature editing when right clicking on the canvas. While this performs the > commit, it then pops up Copy Coordinates. I don’t want the user to see this. > I want my mouse click event to be recognized and not have QGIS use it to > popup the Copy Coordinates. Is there a way to call QgsMapTool.deactivate on > that built in tool just for this instance and then reactivate it? Are you using a custom QgsMapTool subclass? If so, implement the "flags" method and don't return the ShowContextMenu flag. Nyall > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates
I have an event filter on the map canvas that performs a commit during feature editing when right clicking on the canvas. While this performs the commit, it then pops up Copy Coordinates. I don't want the user to see this. I want my mouse click event to be recognized and not have QGIS use it to popup the Copy Coordinates. Is there a way to call QgsMapTool.deactivate on that built in tool just for this instance and then reactivate it? ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer