Unlike every other member of the Button inheritance hierarchy, RadioButton notifies its ButtonPressed listener when it receives focus. This is necessary in order to support selecting radio buttons within a group using the arrow keys (see https://bugs.chromium.org/p/chromium/issues/detail?id=841202).
There are several problems with this setup:
- RadioButton has to manufacture a synthetic ui::event in this case.
- listeners have to listen to each radio button in a group separately, which really never makes sense - listeners will always care about a whole radio group, never about an individual button.
- events are generated in cases when there is no change in state (i.e. when a radio button receives focus via tab but was already selected)
TODO more context, probable solutions
Unlike every other member of the Button inheritance hierarchy, RadioButton notifies its ButtonPressed listener when it receives focus. This is necessary in order to support selecting radio buttons within a group using the arrow keys (see https://bugs.chromium.org/p/chromium/issues/detail?id=841202).
There are several problems with this setup:
- RadioButton has to manufacture a synthetic ui::event in this case.
- listeners have to listen to each radio button in a group separately, which really never makes sense - listeners will always care about a whole radio group, never about an individual button.
- events are generated in cases when there is no change in state (i.e. when an already-selected radio button receives focus or is clicked)
Cleanup options:
- Remove the event field from the callback; it's almost never used, so it might be easy to fix the few users affected
- Choose a synthetic event that is in some sense 'better'
- Have RadioButton fully take control of its notifications instead of delegating some cases to its base classes
- Pull RadioButton out of the hierarchy somehow; not sure what this would look like
- Reify the notion of a radio button group, s.t. it wraps a group of radio buttons and provides listeners with a more directly useful event to listen on
Unlike every other member of the Button inheritance hierarchy, RadioButton notifies its ButtonPressed listener when it receives focus. This is necessary in order to support selecting radio buttons within a group using the arrow keys (see https://bugs.chromium.org/p/chromium/issues/detail?id=841202).
There are several problems with this setup:
- RadioButton has to manufacture a synthetic ui::event in this case.
- listeners have to listen to each radio button in a group separately, which really never makes sense - listeners will always care about a whole radio group, never about an individual button.
- events are generated in cases when there is no change in state (i.e. when an already-selected radio button receives focus or is clicked)
Cleanup options:
- Remove the event field from the callback; it's almost never used, so it might be easy to fix the few users affected (edit: no can do, it has several meaningful usecases)
- Choose a synthetic event that is in some sense 'better'
- Somehow pipe through the keyboard event that precipitated the change in focus, and use that
- Have RadioButton fully take control of its notifications instead of delegating some cases to its base classes; could use a separate notification mechanism in that case
- Pull RadioButton out of the hierarchy somehow; not sure what this would look like
- Reify the notion of a radio button group, s.t. it wraps a group of radio buttons and provides listeners with a more directly useful event to listen on
Comment 1 by tbergquist@chromium.org
, May 24 2018