S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #1 I have a user form with a SeekBar on it that the user can change which will raise the _ValueChanged event. However, I'm also loading in data from a database occasionally and the loaded data can also change the value of the Seekbar. But, I want the commands in the _ValueChanged event to fire only if the user changes the value, not the data. Is it possible to differentiate between the two events? Here's some sample pseudocode: Code: Copy Sub MySeekBar_ValueChanged ...do something...but only if the user changes the value, not the loaded data... End Sub * I just realized that the scenario I proposed wasn't accurate - rewriting it. Last edited: Jun 18, 2017
I have a user form with a SeekBar on it that the user can change which will raise the _ValueChanged event. However, I'm also loading in data from a database occasionally and the loaded data can also change the value of the Seekbar. But, I want the commands in the _ValueChanged event to fire only if the user changes the value, not the data. Is it possible to differentiate between the two events? Here's some sample pseudocode: Code: Copy Sub MySeekBar_ValueChanged ...do something...but only if the user changes the value, not the loaded data... End Sub * I just realized that the scenario I proposed wasn't accurate - rewriting it.
karld Active Member Licensed User Longtime User Jun 18, 2017 #2 Use an IF ELSE statement???? Upvote 0
S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #3 Thanks for the response - I had to rewrite the question. The problem is that the event always fires regardless of who or what triggered the event. I'm wondering if there's a way to know if the user or the data triggered the event. Upvote 0
Thanks for the response - I had to rewrite the question. The problem is that the event always fires regardless of who or what triggered the event. I'm wondering if there's a way to know if the user or the data triggered the event.
karld Active Member Licensed User Longtime User Jun 18, 2017 #4 Well.. I am far from an expert... Can use pass a flag to your event to tell it who called it? Upvote 0
S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #5 That's exactly what I'd like to do, but, from what I understand, the procedure is declared like this: Code: Copy Sub MySeekBar_ValueChanged (index As Float, value As Object) Where the index and value are set automatically by the change, and I don't see a way to include another parameter. Is there a way to include another parameter? Upvote 0
That's exactly what I'd like to do, but, from what I understand, the procedure is declared like this: Code: Copy Sub MySeekBar_ValueChanged (index As Float, value As Object) Where the index and value are set automatically by the change, and I don't see a way to include another parameter. Is there a way to include another parameter?
karld Active Member Licensed User Longtime User Jun 18, 2017 #6 Please post your code so it can be looked at. These little snippets are hard to determine what you are doing. Upvote 0
Please post your code so it can be looked at. These little snippets are hard to determine what you are doing.
S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #7 Here's a copy of the event: Code: Copy Sub MySeekBar_ValueChanged (index As Float, value As Object) CallSub2(Starter, "ReloadData", False) End Sub ReloadData is too long to post, but the general idea looks like this: Code: Copy Sub ReloadData MySeekBar.Value = ValueFromDatabase End Sub The idea is that the ReloadData should only be called when a user changes the value of the SeekBar. But, sometimes, when the data is loaded, it can change the value of the SeekBar, too, which can cause another fire of ReloadData...and possibly an endless loop. Upvote 0
Here's a copy of the event: Code: Copy Sub MySeekBar_ValueChanged (index As Float, value As Object) CallSub2(Starter, "ReloadData", False) End Sub ReloadData is too long to post, but the general idea looks like this: Code: Copy Sub ReloadData MySeekBar.Value = ValueFromDatabase End Sub The idea is that the ReloadData should only be called when a user changes the value of the SeekBar. But, sometimes, when the data is loaded, it can change the value of the SeekBar, too, which can cause another fire of ReloadData...and possibly an endless loop.
S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #8 Btw, another post located here: https://www.b4x.com/android/forum/t...ox-checkedchange-event-from-triggering.72120/ had the same issue, but, in their case, the Checkbox has two events: a) CheckedChanged, and b) Click, which separates the events. Perhaps the SeekBar also has two separate events? Upvote 0
Btw, another post located here: https://www.b4x.com/android/forum/t...ox-checkedchange-event-from-triggering.72120/ had the same issue, but, in their case, the Checkbox has two events: a) CheckedChanged, and b) Click, which separates the events. Perhaps the SeekBar also has two separate events?
S swabygw Active Member Licensed User Longtime User Jun 18, 2017 #9 I found the answer. The SeekBar does, indeed, have a UserChanged boolean parameter. I didn't see it because I've been using a CustomSlideBar library which eliminated it. I modified the library slightly to pass the value and it works. Upvote 0
I found the answer. The SeekBar does, indeed, have a UserChanged boolean parameter. I didn't see it because I've been using a CustomSlideBar library which eliminated it. I modified the library slightly to pass the value and it works.
karld Active Member Licensed User Longtime User Jun 18, 2017 #10 Good Deal! Glad you found it. I was just going to fire up B4A and play with it. Upvote 0