This will work. when the $201 'mouse clicked' event occurs just check that the event source is the canvas as well:
canvas=CreateCanvas(...) Repeat event=WaitEvent() Select event Case $201 ; mouse clicked mx=MouseX(canvas) : gy=MouseY(canvas) If EventSource()=canvas If EventData()=1 ;lmb ;;; LEFT BUTTON CLICKED IN CANVAS EndIf If EventData()=2 ;rmb ;;; RIGHT BUTTON CLICKED IN CANVAS EndIf EndIf End Select Until quit=True