<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Ubuntu">Maybe return True in your eventFilter, so that
      the event is not processed further by other widgets?<br>
      <br>
      Regards,<br>
    </font><br>
    <font face="Ubuntu"><br>
    </font>
    <pre class="moz-signature" cols="72">-- 
Jacky Volpes

Ingénieur SIG - Oslandia</pre>
    <font face="Ubuntu"><br>
    </font><br>
    <div class="moz-cite-prefix">Le 13/04/2023 à 08:11, Catania, Luke A
      ERDC-RDE-GRL-VA CIV via QGIS-Developer a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:014e125ba2cb4e8a8728855f9325c86e@erdc.dren.mil">
      <pre class="moz-quote-pre" wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:qgis-developer-bounces@lists.osgeo.org"><qgis-developer-bounces@lists.osgeo.org></a> 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 <a class="moz-txt-link-rfc2396E" href="mailto:nyall.dawson@gmail.com"><nyall.dawson@gmail.com></a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>
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 <a class="moz-txt-link-rfc2396E" href="mailto:nyall.dawson@gmail.com"><nyall.dawson@gmail.com></a> 
Sent: Wednesday, April 12, 2023 9:09 PM
To: Catania, Luke A ERDC-RDE-GRL-VA CIV <a class="moz-txt-link-rfc2396E" href="mailto:Luke.A.Catania@erdc.dren.mil"><Luke.A.Catania@erdc.dren.mil></a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>
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 <a class="moz-txt-link-rfc2396E" href="mailto:qgis-developer@lists.osgeo.org"><qgis-developer@lists.osgeo.org></a> wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
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?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Are you using a custom QgsMapTool subclass? If so, implement the "flags" method and don't return the ShowContextMenu flag.

Nyall


</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: 
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
Unsubscribe: 
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>