Android Question Separate user and program events

red30

Well-Known Member
Licensed User
Longtime User
For example, I have CheckBox1 and its CheckBox1_CheckedChange event.
If I click on the CheckBox with my finger, I get into the CheckBox1_CheckedChange event. But if I want to set the CheckBox1.Checked = True state somewhere in the program text, then I will also get into the CheckedChange event.
Is it possible to somehow separate these events? So that I can handle separately the events when the user clicks CheckBox1 and the event when CheckBox1.Checked is set somewhere in the code.
Also wondering how to do it with other elements: Spinner, Slider, etc.?
 

toby

Well-Known Member
Licensed User
Longtime User
Try the following
B4X:
CheckBox1.Checked = True
ChangedInCode=True 'Global variable


B4X:
Sub CheckBox1_CheckedChange(Checked As Boolean)
    if ChangedInCode then
        ChangedInCode=False
        return
    end if
 End Sub
 
Last edited:
Upvote 0
Top