No one can know the future, neither the man, nor the machine.
When you click the object, you must wait a _DBLCLICK seconds, to see if a second click comes.
This means that dblclick would be executed immediately, but click only after a short delay.
I tried a solution, based on a timer.
The timer interval is set to 2 * _DBLCLICK
The form has two additional properties.
1) one named _clicks, to pass to the timer the name of the most recent event, click or dblclick.
2) the second named _firstclick, has the default (the "idle") value -_DBLCLICK. The first click set this property to SECONDS()
The timer event check the _clicks property.
a) If _clicks = 'DBLCLICK', then a double click was performed and the proper code is executed
b) If _clicks = 'CLICK' and SECOND() - _firstclick > _DBLCLICK, then was a single click, and the proper code is executed
The original code from click and dblclick was moved in two new myClick and myDblClick methods, to allow the delayed execution.
Here is the code
Code:
PUBLIC ofrm
ofrm = CREATEOBJECT("myform")
ofrm.show()
DEFINE CLASS myform as Form
_clicks = ''
_firstclick = -_DBLCLICK
ADD OBJECT tmr as timer WITH interval = 2 * _DBLCLICK, Enabled = .T.
PROCEDURE click
This._clicks = 'CLICK'
This._firstclick = SECONDS()
ENDPROC
PROCEDURE dblclick
This._clicks = 'DBLCLICK'
ENDPROC
PROCEDURE tmr.timer
IF ThisForm._clicks == 'DBLCLICK'
ThisForm._firstclick = -_DBLCLICK
ThisForm._clicks = ''
ThisForm.myDblClick
ENDIF
IF ThisForm._clicks == 'CLICK' AND SECONDS() - ThisForm._firstclick > _DBLCLICK
ThisForm._firstclick = -_DBLCLICK
ThisForm._clicks = ''
ThisForm.myClick
ENDIF
ENDPROC
PROCEDURE myClick && the code from the click event
GETPICT()
ENDPROC
PROCEDURE myDblClick && the code from the dblclick event
IF MESSAGEBOX('Are you sure',4 + 32 + 256,'Delete') = 6
MESSAGEBOX('Deleted',64,'Success')
ENDIF
ENDPROC
ENDDEFINE
Respectfully,
Vilhelm-Ion Praisach
Resita, Romania