S susu Well-Known Member Licensed User Longtime User Aug 17, 2013 #1 Hi all, I used ScrollChanged event to know when the ScrollView reachs the end but it seems ScrollChanged fired multiple times (or my code is wrong?). Code: Sub sv_ScrollChanged(Position As Int) If Position + sv.Height >= sv.Panel.Height Then sv.ScrollPosition = Position - 100dip numberoflastscroll = numberoflastscroll + 1 Msgbox(numberoflastscroll, "Number of last scroll action") End If End Sub I expected the message box will appears one by one after each time I scroll to the end of scroll view. But now it continually count "2", "3", "4"... when I scroll to the end of scroll view 1 time. Please check the exported project to see the problem. Thank you. Attachments scrollchanged.zip scrollchanged.zip 5.9 KB · Views: 490
Hi all, I used ScrollChanged event to know when the ScrollView reachs the end but it seems ScrollChanged fired multiple times (or my code is wrong?). Code: Sub sv_ScrollChanged(Position As Int) If Position + sv.Height >= sv.Panel.Height Then sv.ScrollPosition = Position - 100dip numberoflastscroll = numberoflastscroll + 1 Msgbox(numberoflastscroll, "Number of last scroll action") End If End Sub I expected the message box will appears one by one after each time I scroll to the end of scroll view. But now it continually count "2", "3", "4"... when I scroll to the end of scroll view 1 time. Please check the exported project to see the problem. Thank you.
Erel B4X founder Staff member Licensed User Longtime User Aug 18, 2013 #2 The scroll changed events are sent to the message queue and then they are processed. This means that multiple events have already been sent when you process the first event. I'm not sure what you are trying to do. However you should probably change your code to check for two levels. First that the position is higher than the max value and then that it is lower than max - delta. Only then you should allow the next "scroll to bottom" event. (such a solution is sometimes named hysteresis) Upvote 0
The scroll changed events are sent to the message queue and then they are processed. This means that multiple events have already been sent when you process the first event. I'm not sure what you are trying to do. However you should probably change your code to check for two levels. First that the position is higher than the max value and then that it is lower than max - delta. Only then you should allow the next "scroll to bottom" event. (such a solution is sometimes named hysteresis)
U uhzeg Member Licensed User Longtime User Feb 26, 2014 #3 susu, I have the same behaviour and I was not able to fix it even with Erel's answer. Have you been able, and if yes, could you please paste your new Code: Sub sv_ScrollChanged(Position As Int) ? Thanks in advance Upvote 0
susu, I have the same behaviour and I was not able to fix it even with Erel's answer. Have you been able, and if yes, could you please paste your new Code: Sub sv_ScrollChanged(Position As Int) ? Thanks in advance