![]() |
![]() |
Document.GetUserClick
Function GetUserClick(x As Double, y As Double, ShiftState As Long, TimeOut As Long, Snap As Boolean, CursorShape As cdrCursorShape) As Long
Member of Document
The GetUserClick method allows the user to specify a point in the document window and return the coordinates of that point back to script. It also retrieves information about the state of the Ctrl, Shift, and Alt keys at the time of the click.
The following code example retrieves the coordinates of the point where the user clicks and draws a circle at that point. The circle fill depends on the modifier key state. If the Shift is pressed while the user clicked, red is applied. If Ctrl is pressed, green is added. If Alt is pressed, blue is applied. Therefore, pressing Ctrl + Shift + Alt produces a yellow circle. The macro loops until the user presses Esc to abort the procedure or time out interval of ten seconds elapses.
Sub Test() Dim x As Double, y As Double Dim Shift As Long Dim b As Boolean Dim s As Shape Dim cr As Long, cg As Long, cb As Long b = False While Not b b = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorEyeDrop) If Not b Then Set s = ActiveLayer.CreateEllipse(x - 0.1, y - 0.1, x + 0.1, y + 0.1) cr = 0 cg = 0 cb = 0 If (Shift And 1) <> 0 Then cr = 255 ' Shift depressed - Add Red If (Shift And 2) <> 0 Then cg = 255 ' Ctrl depressed - Add Green If (Shift And 4) <> 0 Then cb = 255 ' Alt depressed - Add Blue s.Fill.UniformColor.RGBAssign cr, cg, cb End If Wend End Sub
![]() |
![]() |
![]() |
Copyright 2007 Corel Corporation. All rights reserved.