<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">I'm trying to get the mouse position whenever the user clicks the canvas when using a map tool. I've tried this and it works but only with custom map tools, not with defaults like: Select features, Add feature, etc...<br></div><div dir="ltr"><div>This is the script to print in the console the QgsMapMouseEvent.</div><div><br></div><div><font face="monospace">canvas = iface.mapCanvas()<br><br>new_tool = canvas.mapTool()<br>canvas.unsetMapTool(new_tool)<br>old_function = new_tool.canvasPressEvent<br>def canvasPressEvent(mouse):<br>    old_function(mouse)<br>    print(mouse)<br>    <br>new_tool.canvasPressEvent = canvasPressEvent<br>canvas.setMapTool(new_tool)</font><br></div><div><br></div><div>Is it possible to override functions like <a href="https://qgis.org/pyqgis/3.22/gui/QgsMapTool.html#qgis.gui.QgsMapTool.canvasMoveEvent" title="qgis.gui.QgsMapTool.canvasMoveEvent" style="box-sizing:border-box;color:rgb(41,128,185);text-decoration-line:none;font-family:Lato,proxima-nova,"Helvetica Neue",Arial,sans-serif;font-size:14.4px;white-space:nowrap;background-color:rgb(252,252,252)" target="_blank" rel="noreferrer"><code style="box-sizing:border-box;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;font-size:10.8px;white-space:normal;max-width:100%;background:rgb(255,255,255);border:1px solid rgb(225,228,229);padding:2px 5px;color:rgb(64,64,64);overflow-x:auto;font-weight:700"><span style="box-sizing:border-box">canvasMoveEvent</span></code></a>, <a href="https://qgis.org/pyqgis/3.22/gui/QgsMapTool.html#qgis.gui.QgsMapTool.canvasPressEvent" title="qgis.gui.QgsMapTool.canvasPressEvent" style="box-sizing:border-box;color:rgb(41,128,185);text-decoration-line:none;font-family:Lato,proxima-nova,"Helvetica Neue",Arial,sans-serif;font-size:14.4px;white-space:nowrap;background-color:rgb(243,246,246)" target="_blank" rel="noreferrer"><code style="box-sizing:border-box;font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace;font-size:10.8px;white-space:normal;max-width:100%;background:rgb(255,255,255);border:1px solid rgb(225,228,229);padding:2px 5px;color:rgb(64,64,64);overflow-x:auto;font-weight:700"><span style="box-sizing:border-box">canvasPressEvent</span></code></a> on default tools?</div></div>
</div></div>