EZ_TestSpriteClick does not actually test for an actual click. It simply is passed the coordinates of the last click and it just calculates from that position which sprite the coordinates are on.
You have to get the actual mouse click position for the canvas control first, which is done using the EZ_GetCanvasXY command which you can call in the Canvas controls %EZ_Click event.
EZGUI stores the last X, Y position when the left mouse button is pressed down. It generates the %EZ_Click event so you can process it there.
Now let's say you want to drag a sprite around, you can subclass the Canvas control and then in the %EZ_LButtonDown event get the X,Y position of the mouse and then call EZ_TestSpriteClick and then start a drag process to draw the sprite around.
You can use EZ_GetMouseXY instead of EZ_GetCanvasXY when processing it in the %EZ_LButtonDown event.
Here is some old EZGUI 4.0 code (should work) where I drag a sprite around by processing the %EZ_LButtonDown event and using EZ_TestSpriteClick to figure out which sprite needs to be dragged:
UB Form1_Events(CID&, CMsg&, CVal&, Cancel&)
LOCAL X&, Y&, SX&, SY&
STATIC SPN$
SELECT CASE CID&
CASE %EZ_Window
IF CMsg&=%EZ_Started THEN
MakeSprites
END IF
CASE %FORM1_CANVAS1
IF CMsg&=%EZ_SelectCursor THEN
IF App_MoveFlag&=0 THEN
SPN$ = EZ_TestSpriteClick ("Form1", %FORM1_CANVAS1, App_MouseX&, App_MouseY&)
IF SPN$<>"" THEN
EZ_SetCursor "", 4
Cancel&=1
END IF
END IF
END IF
IF CMsg&=%EZ_LButtonDown THEN
EZ_GetMouseXY CVal&, X&, Y&
SPN$ = EZ_TestSpriteClick ("Form1", %FORM1_CANVAS1, X&, Y&)
IF SPN$<>"" THEN
IF EZ_GetSpriteXY (SPN$, SX&, SY&) THEN
EZ_SetCaptureEx EZ_Handle("Form1", %FORM1_CANVAS1)
EZ_SetCursor "", 1
App_MoveFlag&=1
App_OffsetX&=X&-SX&
App_OffsetY&=Y&-SY&
END IF
END IF
END IF
IF CMsg&=%EZ_MouseMove THEN
EZ_GetMouseXY CVal&, X&, Y&
App_MouseX&=X&
App_MouseY&=Y&
IF App_MoveFlag& THEN
EZ_MoveSprites SPN$, X&-App_OffsetX&, Y&-App_OffsetY&, 0
EZ_UpdateClient "Form1", %FORM1_CANVAS1
END IF
END IF
IF CMsg&=%EZ_LButtonUp THEN
App_MoveFlag&=0
EZ_SetCaptureEx 0
END IF
CASE ELSE
END SELECT
END SUB
Notice when dragging a sprite you need to capture the mouse once you process the %EZ_LButtonDown event.