Example of disabling one checkbox when another is enabled

Hi Everyone.

I have, what seems to be, a pretty simple task of toggling checkboxes based on the state of another checkbox.

I’ve looked into bind and add_notifier(), but something I’m doing isn’t quite right. Can someone provide a quick pseudo code example, or better yet, an actual example of doing this?

To be clear, what I’m trying to do:

When checkbox A becomes enabled, checkbox B becomes disabled.

Thanks,

Give checkbox B an id and disable it from within checkbox A’s notifier:

vb.checkbox {
  notifier = function(value)
    if value == true then vb.views.checkbox-b.value = false end
  end
}

vb.checkbox {
  id = "checkbox-b"
}
1 Like

@Achenar , simple. thank you very much.

Taking the example above, if you want to enable and disable:

vb.checkbox {
  notifier = function(value) vb.views.checkbox-b.value = not value end
}

vb.checkbox {
  id = "checkbox-b"
}

In this way you will always have the inverse in the other checkbox. And you can do the same in the other checkbox.

1 Like