Home/ Reference/ Events

doc.GetUserClick(Prompt)

Pauses the script until the user clicks the canvas, then returns that point. Every "click where you want it drawn" tool runs on this.

Signature

doc.GetUserClick(Prompt)

Notes

Pauses the script until the user clicks the canvas, then returns that point. Every "click where you want it drawn" tool runs on this.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
point = doc.GetUserClick("Click once on the page to set the start point")

if point is None or len(point) < 2:
    print("Cancelled by the user")
else:
    x, y = point[0], point[1]
    print("You clicked: ", x, y)

    layer = doc.ActivePage.ActiveLayer
    circle = layer.CreateEllipse2(x, y, 20 / 25.4)   # draw a circle of radius 20mm at that point
    circle.Fill.UniformColor.RGBAssign(0, 133, 205)

About this section: Events

Events — waiting for user interaction.

Other entries in this section