B4J Question Double Clicking a Button

tsteward

Well-Known Member
Licensed User
Is there a way to detect double clicking or long press on a button created as B4XView?
 

Sandman

Well-Known Member
Licensed User
Double click: just measure the time between the clicks. If it's under your threshold, it's a double click.

(Don't know about long press, sorry.)

I'm curious, why do you want the user to double click buttons?
 

tsteward

Well-Known Member
Licensed User
Double click: just measure the time between the clicks. If it's under your threshold, it's a double click.

(Don't know about long press, sorry.)

I'm curious, why do you want the user to double click buttons?
Well long click would be better, double click was just an option if I can't detect long click.
I want this because my android app performs different functions depending on button press or button long press.
I want my B4J version of the app to behave similarly.
 

tsteward

Well-Known Member
Licensed User
B4X:
Private Sub Button1_MouseClicked (EventData As MouseEvent)
    If EventData.ClickCount = 2 Then
        Log("double click")
    End If
End Sub
Clicking the button slowly works as a single click :)

Double clicking fires as a single click then fires again as a double click. How can I supress this single click :rolleyes:
 

Star-Dust

Expert
Licensed User
Clicking the button slowly works as a single click :)

Double clicking fires as a single click then fires again as a double click. How can I supress this single click :rolleyes:
It depends on the settings you have put on windows. You can set the interval between the first click and the second (slow or fast) from the control panel

Or create a click counter yourself with a global variable that increments with each click. But in any case after a certain time it must reset otherwise you would have problems that it continues to count and distort the results ... (You may also have reported a double click with two clicks 10 minutes or an hour apart ... ) I do not recommend the latter solution
 
Top