pliroforikos Active Member Licensed User Mar 2, 2022 #1 Hello world. I have some clvs with names of my students. When i click on a student then a new clv shows more details about him/her. For example the firstname, surname, tests points etc. The data taken from a database in web. The problem is when i double click the list item it fetches student information 2 times or more if i clicked fast enough. The question is how i can prevent double or triple clicking on a list item before first click event run.
Hello world. I have some clvs with names of my students. When i click on a student then a new clv shows more details about him/her. For example the firstname, surname, tests points etc. The data taken from a database in web. The problem is when i double click the list item it fetches student information 2 times or more if i clicked fast enough. The question is how i can prevent double or triple clicking on a list item before first click event run.
AnandGupta Expert Licensed User Longtime User Mar 2, 2022 #2 There are multiple solution. You can use public variable and set it true in called sub, return from sub if found true (second click) , set it false after done. Or disable the clv on click, etc. Upvote 0
There are multiple solution. You can use public variable and set it true in called sub, return from sub if found true (second click) , set it false after done. Or disable the clv on click, etc.
udg Expert Licensed User Longtime User Mar 2, 2022 #3 Another, simple, no-code solution: don't click twice Sorry, I couldn't resist. Upvote 0
AnandGupta Expert Licensed User Longtime User Mar 2, 2022 #4 udg said: Another, simple, no-code solution: don't click twice Sorry, I couldn't resist. Click to expand... Actually the op will never click twice, but his users will. I have faced this in nearly all my released products. It looks like the users are hell bent to find errors. GOD Bless them. Upvote 0
udg said: Another, simple, no-code solution: don't click twice Sorry, I couldn't resist. Click to expand... Actually the op will never click twice, but his users will. I have faced this in nearly all my released products. It looks like the users are hell bent to find errors. GOD Bless them.
pliroforikos Active Member Licensed User Mar 2, 2022 #5 AnandGupta said: There are multiple solution. You can use public variable and set it true in called sub, return from sub if found true (second click) , set it false after done. Or disable the clv on click, etc. Click to expand... I have already used first proposal like this B4X: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) If lockCLV = True Then Return End If lockCLV = True without succes, and at the end of clvStudents_ItemClick i turn flag to False Are u using other place to check flag? Upvote 0
AnandGupta said: There are multiple solution. You can use public variable and set it true in called sub, return from sub if found true (second click) , set it false after done. Or disable the clv on click, etc. Click to expand... I have already used first proposal like this B4X: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) If lockCLV = True Then Return End If lockCLV = True without succes, and at the end of clvStudents_ItemClick i turn flag to False Are u using other place to check flag?
AnandGupta Expert Licensed User Longtime User Mar 2, 2022 #6 Just add log and check, Code: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) log("lockCLV " & lockCLV) If lockCLV = True Then Return End If lockCLV = True Upvote 0
Just add log and check, Code: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) log("lockCLV " & lockCLV) If lockCLV = True Then Return End If lockCLV = True
pliroforikos Active Member Licensed User Mar 2, 2022 #7 In both clicks flag is false. Maybe because i am using resumable function to get my data the program continues and flag goes back to true at then end? Upvote 0
In both clicks flag is false. Maybe because i am using resumable function to get my data the program continues and flag goes back to true at then end?
AnandGupta Expert Licensed User Longtime User Mar 2, 2022 #8 pliroforikos said: In both clicks flag is false. Maybe because i am using resumable function to get my data the program continues and flag goes back to true at then end? Click to expand... Well posting your project (or sample one) may help experts here to solve it. Upvote 0
pliroforikos said: In both clicks flag is false. Maybe because i am using resumable function to get my data the program continues and flag goes back to true at then end? Click to expand... Well posting your project (or sample one) may help experts here to solve it.
pliroforikos Active Member Licensed User Mar 2, 2022 #9 Thank you very much for your time, It's a bit difficult to reproduce the code without my data. I 'll continue my efforts. Upvote 0
Thank you very much for your time, It's a bit difficult to reproduce the code without my data. I 'll continue my efforts.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Mar 2, 2022 #10 Here is a suggestion, without seeing some code, I can't be sure... The problem is likely to be that you are resetting the lockClv to false without waiting for the resumable sub to complete for example: B4X: Copy lockClV = true PerformResumeableSub LockCLV = false in the example, lockCLV will only be true for a *VERY* short space of time if you write the code like this: B4X: Copy lockCLV = true wait for (performResumeablesub) complete lockclv = false then lockCLV will not get reset until the resumeablesub is complete Upvote 0
Here is a suggestion, without seeing some code, I can't be sure... The problem is likely to be that you are resetting the lockClv to false without waiting for the resumable sub to complete for example: B4X: Copy lockClV = true PerformResumeableSub LockCLV = false in the example, lockCLV will only be true for a *VERY* short space of time if you write the code like this: B4X: Copy lockCLV = true wait for (performResumeablesub) complete lockclv = false then lockCLV will not get reset until the resumeablesub is complete
Sagenut Expert Licensed User Longtime User Mar 2, 2022 #11 Everything is managed in the ItemClick event? What about B4X: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) clvStudents.AsView.Enabled = False ' Here do the Database read and other CLV compilation clvStudents.AsView.Enabled = True Upvote 0
Everything is managed in the ItemClick event? What about B4X: Copy Private Sub clvStudents_ItemClick (Index As Int, Value As Object) clvStudents.AsView.Enabled = False ' Here do the Database read and other CLV compilation clvStudents.AsView.Enabled = True
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Mar 2, 2022 #12 Ok, if the database read or other operations use resumeable subs you need to use wait for or the processing will continue at this level. see this thread which may help explain: Resumable Subs - order of execution Hi all, within a initialize of a class I run three resumable subs: "Download1", "Download2" and "Download3": 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize Download1 'Resumable Sub1 Download2 'Resumable Sub2 Download3 'Resumable Sub3... www.b4x.com and [B4X] Resumable subs that return values (ResumableSub) Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to the parent. Example: Sub Button1_Click Sum(1, 2) Log("after sum") End Sub Sub Sum(a As Int, b As Int) Sleep(100) 'this will cause the code flow to return to the parent Log(a + b) End Sub... www.b4x.com I would move the work out to a sub so that you can wrap the whole lot in one wait for at the itemclick level. Upvote 0
Ok, if the database read or other operations use resumeable subs you need to use wait for or the processing will continue at this level. see this thread which may help explain: Resumable Subs - order of execution Hi all, within a initialize of a class I run three resumable subs: "Download1", "Download2" and "Download3": 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize Download1 'Resumable Sub1 Download2 'Resumable Sub2 Download3 'Resumable Sub3... www.b4x.com and [B4X] Resumable subs that return values (ResumableSub) Remember that that a call to Sleep or Wait For in a resumable sub causes the code flow to return to the parent. Example: Sub Button1_Click Sum(1, 2) Log("after sum") End Sub Sub Sum(a As Int, b As Int) Sleep(100) 'this will cause the code flow to return to the parent Log(a + b) End Sub... www.b4x.com I would move the work out to a sub so that you can wrap the whole lot in one wait for at the itemclick level.
pliroforikos Active Member Licensed User Mar 2, 2022 #13 Thank you all i will check asap your suggestions and i'll tell you about. Now i am using this method as described above with a small improve. lockCLV = true wait for (performResumeablesub) complete lockclv = false Upvote 0
Thank you all i will check asap your suggestions and i'll tell you about. Now i am using this method as described above with a small improve. lockCLV = true wait for (performResumeablesub) complete lockclv = false