This condition is a bit tricky. You can't use .OnClick since it will capture button void action either by keyboard (space and enter) or by mouse click. If you want to determine user validate button by specific actions, you need to use .OnKeyUp and .OnMouseDown to isolate each input access. See example below:
DECLARE SUB keypress(key AS BYTE)
DECLARE SUB mouseclk
CREATE form AS QFORM
CREATE mybtn AS QBUTTON
CAPTION = "click me"
onkeyup = keypress
onmousedown = mouseclk
END CREATE
SHOWMODAL
END CREATE
SUB keypress(key AS BYTE)
IF key=13 THEN
SHOWMESSAGE "Enter key"
ELSE
SHOWMESSAGE "Other key"
END IF
END SUB
SUB mouseclk
SHOWMESSAGE "mouse click"
END SUB
Don
|