B4J Question Timing Issues

MrKim

Well-Known Member
Licensed User
Longtime User
Edit: Well, Sleep(10) DID work. I guess it required stopping and restarting the program possibly adding a sleep in debug mode doesn't actually make it work?

I have a CustomListView and the list contains a BBCodeView that has url links. I am doing things with both the url link and CLV_ItemClick .

If the BBCodeView_LinkClicked is clicked I want to ignore the CLV_ItemClick event.

The problem is the CLV click event happens before the BBCodeView_LinkClicked event so I can't set a flag to stop CLV_ItemClick.

I tried Sleep in the CLV_ItemClick event hoping it would allow BBCodeView_LinkClicked to fire but no joy.

Any ideas?
 
Last edited:

Chris2

Active Member
Licensed User
Can you use a 'Wait For...' at the start of the CLV_ItemClick event to wait for BBCodeView_LinkClicked to complete?

That might create a more robust solution in case sleep(10) isn't sufficient on different devices.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Can you use a 'Wait For...' at the start of the CLV_ItemClick event to wait for BBCodeView_LinkClicked to complete?

That might create a more robust solution in case sleep(10) isn't sufficient on different device.
Well, the problem with that is that if they DIDN'T click on a link then it would be waiting forever.
Unless there is a way to set a timeout on Wait For...??
 
Upvote 0

Chris2

Active Member
Licensed User
Just thinking out loud & completely untested...
B4X:
Sub Process_Globals
    Dim t As Timer
End Sub

Sub AppStart (Form1 As Form, Args() As String)
 
        t.Initialize("t", 5000) '5 seconds
    
End Sub


Sub BBCodeView_LinkClicked

'your code here...

        CallSubDelayed(Me, "LinkClicked_Complete")

End Sub


Sub CLV_ItemClick
    
    t.Enabled=True
    Wait For (LinkClicked_Complete) Complete (unused As Boolean)

'your code here
    
End Sub


Private Sub t_Tick

    CallSubDelayed(Me, "LinkClicked_Complete")

End Sub


Sub LinkClicked_Complete

        Return t.Enabled=False
    
End Sub
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Just thinking out loud & completely untested...
B4X:
Sub Process_Globals
    Dim t As Timer
End Sub

Sub AppStart (Form1 As Form, Args() As String)
 
        t.Initialize("t", 5000) '5 seconds
   
End Sub


Sub BBCodeView_LinkClicked

'your code here...

        CallSubDelayed(Me, "LinkClicked_Complete")

End Sub


Sub CLV_ItemClick
   
    t.Enabled=True
    Wait For (LinkClicked_Complete) Complete (unused As Boolean)

'your code here
   
End Sub


Private Sub t_Tick

    CallSubDelayed(Me, "LinkClicked_Complete")

End Sub


Sub LinkClicked_Complete

        Return t.Enabled=False
   
End Sub
Thanks, but sleep seems very reliable and simple is best...
 
Upvote 0
Top