Use base::Callback for button/link listeners |
||||
Issue description
Uses of base::Callback instead of a ButtonListener removes the need to check who sent the event (whenever the listener can receive >1 events).
Example pseudo/C++ instead of base::Callback:
AddChildView(new Button([this]() { DoEvent1(); });
vs.
enum EventTags {
kEvent1,
};
...
views::Button* button = new Button(this);
button->set_tag(kEvent1);
AddChildView(button);
...
OnClicked(sender, ...) {
if (sender->tag() == kEvent1) {
DoEvent1();
} else if (...) {
DoEvent2();
} else {
DoEvent3();
}
Which is harder to follow/easier to get wrong (if you in this case added Event4, DoEvent3() would be triggered for that button press).
,
Dec 5 2017
I think this is a good idea, and I'm going to leave open.
,
Dec 6 2017
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks!
,
Sep 13
Archiving old bugs that haven't been actively assigned in over 180 days. If you feel this issue should still be addressed, feel free to reopen it or to file a new issue. Thanks! |
||||
►
Sign in to add a comment |
||||
Comment 1 by pbos@chromium.org
, Dec 5 2017