blob: f35b178e2c4fdea4aa7dbb154c294076605830ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "views/controls/button/button.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// Button, public:
Button::~Button() {
}
void Button::SetTooltipText(const std::wstring& tooltip_text) {
tooltip_text_ = tooltip_text;
TooltipTextChanged();
}
void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) {
accessible_shortcut_.assign(shortcut);
}
////////////////////////////////////////////////////////////////////////////////
// Button, View overrides:
bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) {
if (tooltip_text_.empty())
return false;
*tooltip = tooltip_text_;
return true;
}
std::wstring Button::GetAccessibleKeyboardShortcut() {
return accessible_shortcut_;
}
AccessibilityTypes::Role Button::GetAccessibleRole() {
return AccessibilityTypes::ROLE_PUSHBUTTON;
}
////////////////////////////////////////////////////////////////////////////////
// Button, protected:
Button::Button(ButtonListener* listener)
: listener_(listener),
tag_(-1),
mouse_event_flags_(0) {
set_accessibility_focusable(true);
}
void Button::NotifyClick(const views::Event& event) {
mouse_event_flags_ = event.IsMouseEvent() ? event.GetFlags() : 0;
// We can be called when there is no listener, in cases like double clicks on
// menu buttons etc.
if (listener_)
listener_->ButtonPressed(this, event);
// NOTE: don't attempt to reset mouse_event_flags_ as the listener may have
// deleted us.
}
} // namespace views
|