Previous Document Next Document
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.

Parameters
Description
x
Returns the x-coordinate of the selection click
y
Returns the y-coordinate of the selection click
ShiftState
Specifies the shift state
TimeOut
Specifies the amount of time, in seconds, to wait for the user to click
The default value for this parameter is 10.
Snap
Specifies whether to recognize the snap
CursorShape
Specifies the shape of the cursor

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 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.