KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Use On Clicked OR On Double Clicked not Both
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: July 19, 2019

It is typically not recommended to use both the On Clicked form event and the On Double Clicked event for a single item because they can cause interferences with each other. To attempt to trigger an On Double Clicked event, two Clicks must be performed, which should trigger the On Clicked event twice. If both events are needed it may require that some flags and timers are implemented to prevent the triggering of the On Clicked event twice when a double click event should be triggered. As such it is not recommended to enable both events on an object unless planned to be handled properly.

Example the following will set a flag and a timer when the first click is performed, and if a second click is performed fast enough soon after it will register a double click, if not it will register a single click:

// Form Object's Method:
If (Form event=On Clicked)
  If (clicked_b=True)
    clicked_b:=False
    ALERT("Double Clicked") //Do your double clicked code
  Else
    clicked_b:=True
    SET TIMER(20) //grace period
  End if
End if


// Form Method:
Case of
  : (Form event=On Load)
    clicked_b:=False
  : (Form event=On Timer)
    If (clicked_b=True)
      clicked_b:=False
      ALERT("Single Clicked")
    End if
End case