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...
This is the script to print in the console the QgsMapMouseEvent.

canvas = iface.mapCanvas()

new_tool = canvas.mapTool()
canvas.unsetMapTool(new_tool)
old_function = new_tool.canvasPressEvent
def canvasPressEvent(mouse):
    old_function(mouse)
    print(mouse)

new_tool.canvasPressEvent = canvasPressEvent
canvas.setMapTool(new_tool)

Is it possible to override functions like canvasMoveEvent
<https://qgis.org/pyqgis/3.22/gui/QgsMapTool.html#qgis.gui.QgsMapTool.canvasMoveEvent>
, canvasPressEvent
<https://qgis.org/pyqgis/3.22/gui/QgsMapTool.html#qgis.gui.QgsMapTool.canvasPressEvent>
on
default tools?
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to