Android Question Determine whether user raised event or not

swabygw

Active Member
Licensed User
Longtime User
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:

B4X:
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:

swabygw

Active Member
Licensed User
Longtime User
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

karld

Active Member
Licensed User
Longtime User
Well.. I am far from an expert...

Can use pass a flag to your event to tell it who called it?
 
Upvote 0

swabygw

Active Member
Licensed User
Longtime User
That's exactly what I'd like to do, but, from what I understand, the procedure is declared like this:

B4X:
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

karld

Active Member
Licensed User
Longtime User
Please post your code so it can be looked at. These little snippets are hard to determine what you are doing.
 
Upvote 0

swabygw

Active Member
Licensed User
Longtime User
Here's a copy of the event:
B4X:
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:
B4X:
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

swabygw

Active Member
Licensed User
Longtime User
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

karld

Active Member
Licensed User
Longtime User
Good Deal!
Glad you found it. I was just going to fire up B4A and play with it.
 
Upvote 0
Top