New issue
Advanced search Search tips

Issue 772945 link

Starred by 1 user

Issue metadata

Status: Archived
Owner: ----
Closed: Sep 13
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Use base::Callback for button/link listeners

Project Member Reported by pbos@chromium.org, Oct 9 2017

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).
 

Comment 1 by pbos@chromium.org, Dec 5 2017

Status: WontFix (was: Assigned)
Self-imposed bugruptcy, I probably won't get around to this (or I'll reopen).

Comment 2 by sky@chromium.org, Dec 5 2017

Labels: CleanUp
Owner: ----
Status: Available (was: WontFix)
I think this is a good idea, and I'm going to leave open.

Comment 3 by pbos@chromium.org, Dec 6 2017

Cc: pbos@chromium.org
Status: Archived (was: Available)
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!
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