summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/custom_button.cc6
-rw-r--r--views/controls/button/menu_button.cc3
-rw-r--r--views/controls/button/native_button.cc10
-rw-r--r--views/controls/combobox/combobox.cc4
-rw-r--r--views/controls/link.cc8
-rw-r--r--views/controls/menu/menu_win.cc3
-rw-r--r--views/controls/menu/native_menu_gtk.cc3
-rw-r--r--views/controls/menu/native_menu_win.cc3
-rw-r--r--views/controls/native_control.cc5
-rw-r--r--views/controls/native_control.h3
-rw-r--r--views/controls/scrollbar/bitmap_scroll_bar.cc19
-rw-r--r--views/controls/scrollbar/native_scroll_bar_win.cc19
-rw-r--r--views/controls/table/group_table_view.cc25
-rw-r--r--views/controls/table/group_table_view.h2
-rw-r--r--views/controls/table/table_view.cc12
-rw-r--r--views/controls/table/table_view.h6
-rw-r--r--views/controls/table/table_view_observer.h2
-rw-r--r--views/controls/textfield/native_textfield_win.cc7
-rw-r--r--views/controls/textfield/textfield.cc9
-rw-r--r--views/controls/tree/tree_view.cc7
-rw-r--r--views/controls/tree/tree_view.h3
21 files changed, 81 insertions, 78 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index e507d93..348e527 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -175,10 +175,10 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) {
// Space sets button state to pushed. Enter clicks the button. This matches
// the Windows native behavior of buttons, where Space clicks the button
// on KeyRelease and Enter clicks the button on KeyPressed.
- if (e.GetCharacter() == base::VKEY_SPACE) {
+ if (e.GetKeyCode() == base::VKEY_SPACE) {
SetState(BS_PUSHED);
return true;
- } else if (e.GetCharacter() == base::VKEY_RETURN) {
+ } else if (e.GetKeyCode() == base::VKEY_RETURN) {
SetState(BS_NORMAL);
NotifyClick(e);
return true;
@@ -189,7 +189,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) {
bool CustomButton::OnKeyReleased(const KeyEvent& e) {
if (state_ != BS_DISABLED) {
- if (e.GetCharacter() == base::VKEY_SPACE) {
+ if (e.GetKeyCode() == base::VKEY_SPACE) {
SetState(BS_NORMAL);
NotifyClick(e);
return true;
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index 25a415d..5b353f3 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -214,7 +214,8 @@ void MenuButton::OnMouseReleased(const MouseEvent& e,
// When the space bar or the enter key is pressed we need to show the menu.
bool MenuButton::OnKeyReleased(const KeyEvent& e) {
#if defined(OS_WIN)
- if ((e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN)) {
+ if ((e.GetKeyCode() == base::VKEY_SPACE) ||
+ (e.GetKeyCode() == base::VKEY_RETURN)) {
return Activate();
}
#else
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index e36719c..811fb56 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -10,6 +10,7 @@
#endif
#include "app/l10n_util.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
namespace views {
@@ -73,17 +74,12 @@ void NativeButton::SetLabel(const std::wstring& label) {
}
void NativeButton::SetIsDefault(bool is_default) {
-#if defined(OS_WIN)
- int return_code = VK_RETURN;
-#else
- int return_code = GDK_Return;
-#endif
if (is_default == is_default_)
return;
if (is_default)
- AddAccelerator(Accelerator(return_code, false, false, false));
+ AddAccelerator(Accelerator(base::VKEY_RETURN, false, false, false));
else
- RemoveAccelerator(Accelerator(return_code, false, false, false));
+ RemoveAccelerator(Accelerator(base::VKEY_RETURN, false, false, false));
SetAppearsAsDefault(is_default);
}
diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc
index 5c5596f..e184dcb 100644
--- a/views/controls/combobox/combobox.cc
+++ b/views/controls/combobox/combobox.cc
@@ -69,10 +69,10 @@ void Combobox::SetEnabled(bool flag) {
native_wrapper_->UpdateEnabled();
}
-// VK_ESCAPE should be handled by this view when the drop down list is active.
+// VKEY_ESCAPE should be handled by this view when the drop down list is active.
// In other words, the list should be closed instead of the dialog.
bool Combobox::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
- if (e.GetCharacter() != base::VKEY_ESCAPE ||
+ if (e.GetKeyCode() != base::VKEY_ESCAPE ||
e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) {
return false;
}
diff --git a/views/controls/link.cc b/views/controls/link.cc
index f2887e0..6619568 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -10,6 +10,7 @@
#include "app/gfx/color_utils.h"
#include "app/gfx/font.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "views/event.h"
@@ -123,8 +124,8 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) {
bool Link::OnKeyPressed(const KeyEvent& e) {
#if defined(OS_WIN)
- bool activate = ((e.GetCharacter() == VK_SPACE) ||
- (e.GetCharacter() == VK_RETURN));
+ bool activate = ((e.GetKeyCode() == base::VKEY_SPACE) ||
+ (e.GetKeyCode() == base::VKEY_RETURN));
#else
bool activate = false;
NOTIMPLEMENTED();
@@ -146,7 +147,8 @@ bool Link::OnKeyPressed(const KeyEvent& e) {
bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
#if defined(OS_WIN)
// Make sure we don't process space or enter as accelerators.
- return (e.GetCharacter() == VK_SPACE) || (e.GetCharacter() == VK_RETURN);
+ return (e.GetKeyCode() == base::VKEY_SPACE) ||
+ (e.GetKeyCode() == base::VKEY_RETURN);
#else
NOTIMPLEMENTED();
return false;
diff --git a/views/controls/menu/menu_win.cc b/views/controls/menu/menu_win.cc
index 68cc8ff..852304f 100644
--- a/views/controls/menu/menu_win.cc
+++ b/views/controls/menu/menu_win.cc
@@ -11,6 +11,7 @@
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
#include "base/gfx/rect.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
@@ -441,7 +442,7 @@ void MenuWin::AddMenuItemInternal(int index,
delegate()->GetLabel(item_id) : label);
// Find out if there is a shortcut we need to append to the label.
- views::Accelerator accelerator(0, false, false, false);
+ views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false);
if (delegate() && delegate()->GetAcceleratorInfo(item_id, &accelerator)) {
actual_label += L'\t';
actual_label += accelerator.GetShortcutText();
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index 55e10ae..7bcb7b9 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/gfx/gtk_util.h"
+#include "base/keyboard_codes.h"
#include "base/string_util.h"
#include "base/time.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -162,7 +163,7 @@ void NativeMenuGtk::AddMenuItemAt(int index,
submenu->GetNativeMenu());
}
- views::Accelerator accelerator(0, false, false, false);
+ views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false);
if (model_->GetAcceleratorAt(index, &accelerator)) {
// TODO(beng): accelerators w/gtk_widget_add_accelerator.
}
diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc
index f078d71..0af8a9af 100644
--- a/views/controls/menu/native_menu_win.cc
+++ b/views/controls/menu/native_menu_win.cc
@@ -8,6 +8,7 @@
#include "app/gfx/font.h"
#include "app/l10n_util.h"
#include "app/l10n_util_win.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/stl_util-inl.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -458,7 +459,7 @@ void NativeMenuWin::UpdateMenuItemInfoForString(
Menu2Model::ItemType type = model_->GetTypeAt(model_index);
if (type != Menu2Model::TYPE_SUBMENU) {
// Add accelerator details to the label if provided.
- views::Accelerator accelerator(0, false, false, false);
+ views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false);
if (model_->GetAcceleratorAt(model_index, &accelerator)) {
formatted += L"\t";
formatted += accelerator.GetShortcutText();
diff --git a/views/controls/native_control.cc b/views/controls/native_control.cc
index 0c89664..700da66 100644
--- a/views/controls/native_control.cc
+++ b/views/controls/native_control.cc
@@ -11,6 +11,7 @@
#include <atlmisc.h>
#include "app/l10n_util_win.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/win_util.h"
#include "views/background.h"
@@ -363,8 +364,8 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, UINT message,
DCHECK(native_control);
if (message == WM_KEYDOWN &&
- native_control->OnKeyDown(static_cast<int>(w_param))) {
- return 0;
+ native_control->OnKeyDown(win_util::WinToKeyboardCode(w_param))) {
+ return 0;
} else if (message == WM_SETFOCUS) {
// Let the focus manager know that the focus changed.
FocusManager* focus_manager = native_control->GetFocusManager();
diff --git a/views/controls/native_control.h b/views/controls/native_control.h
index 972ef36..ed565e6 100644
--- a/views/controls/native_control.h
+++ b/views/controls/native_control.h
@@ -7,6 +7,7 @@
#include <windows.h>
+#include "base/keyboard_codes.h"
#include "views/view.h"
namespace views {
@@ -79,7 +80,7 @@ class NativeControl : public View {
// Invoked when a key is pressed on the control.
// Should return true if the key message was processed, false otherwise.
- virtual bool OnKeyDown(int virtual_key_code) { return false; }
+ virtual bool OnKeyDown(base::KeyboardCode virtual_key_code) { return false; }
// Returns additional extended style flags. When subclasses call
// CreateWindowEx in order to create the underlying control, they must OR the
diff --git a/views/controls/scrollbar/bitmap_scroll_bar.cc b/views/controls/scrollbar/bitmap_scroll_bar.cc
index b04e0b0..98a95ff 100644
--- a/views/controls/scrollbar/bitmap_scroll_bar.cc
+++ b/views/controls/scrollbar/bitmap_scroll_bar.cc
@@ -11,6 +11,7 @@
#include "app/gfx/canvas.h"
#include "app/l10n_util.h"
#include "base/compiler_specific.h"
+#include "base/keyboard_codes.h"
#include "base/message_loop.h"
#include "grit/app_strings.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -494,33 +495,33 @@ bool BitmapScrollBar::OnMouseWheel(const MouseWheelEvent& event) {
bool BitmapScrollBar::OnKeyPressed(const KeyEvent& event) {
ScrollAmount amount = SCROLL_NONE;
- switch (event.GetCharacter()) {
- case VK_UP:
+ switch (event.GetKeyCode()) {
+ case base::VKEY_UP:
if (!IsHorizontal())
amount = SCROLL_PREV_LINE;
break;
- case VK_DOWN:
+ case base::VKEY_DOWN:
if (!IsHorizontal())
amount = SCROLL_NEXT_LINE;
break;
- case VK_LEFT:
+ case base::VKEY_LEFT:
if (IsHorizontal())
amount = SCROLL_PREV_LINE;
break;
- case VK_RIGHT:
+ case base::VKEY_RIGHT:
if (IsHorizontal())
amount = SCROLL_NEXT_LINE;
break;
- case VK_PRIOR:
+ case base::VKEY_PRIOR:
amount = SCROLL_PREV_PAGE;
break;
- case VK_NEXT:
+ case base::VKEY_NEXT:
amount = SCROLL_NEXT_PAGE;
break;
- case VK_HOME:
+ case base::VKEY_HOME:
amount = SCROLL_START;
break;
- case VK_END:
+ case base::VKEY_END:
amount = SCROLL_END;
break;
}
diff --git a/views/controls/scrollbar/native_scroll_bar_win.cc b/views/controls/scrollbar/native_scroll_bar_win.cc
index b15be33..00b3b8c 100644
--- a/views/controls/scrollbar/native_scroll_bar_win.cc
+++ b/views/controls/scrollbar/native_scroll_bar_win.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <string>
+#include "base/keyboard_codes.h"
#include "base/message_loop.h"
#include "base/window_impl.h"
#include "views/controls/scrollbar/native_scroll_bar.h"
@@ -229,32 +230,32 @@ bool NativeScrollBarWin::OnKeyPressed(const KeyEvent& event) {
if (!sb_container_)
return false;
int code = -1;
- switch (event.GetCharacter()) {
- case VK_UP:
+ switch (event.GetKeyCode()) {
+ case base::VKEY_UP:
if (!native_scroll_bar_->IsHorizontal())
code = SB_LINEUP;
break;
- case VK_PRIOR:
+ case base::VKEY_PRIOR:
code = SB_PAGEUP;
break;
- case VK_NEXT:
+ case base::VKEY_NEXT:
code = SB_PAGEDOWN;
break;
- case VK_DOWN:
+ case base::VKEY_DOWN:
if (!native_scroll_bar_->IsHorizontal())
code = SB_LINEDOWN;
break;
- case VK_HOME:
+ case base::VKEY_HOME:
code = SB_TOP;
break;
- case VK_END:
+ case base::VKEY_END:
code = SB_BOTTOM;
break;
- case VK_LEFT:
+ case base::VKEY_LEFT:
if (native_scroll_bar_->IsHorizontal())
code = SB_LINELEFT;
break;
- case VK_RIGHT:
+ case base::VKEY_RIGHT:
if (native_scroll_bar_->IsHorizontal())
code = SB_LINERIGHT;
break;
diff --git a/views/controls/table/group_table_view.cc b/views/controls/table/group_table_view.cc
index 5f26756..a70515d 100644
--- a/views/controls/table/group_table_view.cc
+++ b/views/controls/table/group_table_view.cc
@@ -61,7 +61,7 @@ void GroupTableView::SyncSelection() {
}
}
-void GroupTableView::OnKeyDown(unsigned short virtual_keycode) {
+bool GroupTableView::OnKeyDown(base::KeyboardCode virtual_keycode) {
// In a list view, multiple items can be selected but only one item has the
// focus. This creates a problem when the arrow keys are used for navigating
// between items in the list view. An example will make this more clear:
@@ -87,9 +87,9 @@ void GroupTableView::OnKeyDown(unsigned short virtual_keycode) {
// detect that one of the arrow keys is pressed. Thus, when it comes time
// for the list view control to actually switch the focus, the right item
// will be selected.
- if ((virtual_keycode != VK_UP) && (virtual_keycode != VK_DOWN)) {
- TableView::OnKeyDown(virtual_keycode);
- return;
+ if ((virtual_keycode != base::VKEY_UP) &&
+ (virtual_keycode != base::VKEY_DOWN)) {
+ return TableView::OnKeyDown(virtual_keycode);
}
// We start by finding the index of the item with the focus. If no item
@@ -102,27 +102,28 @@ void GroupTableView::OnKeyDown(unsigned short virtual_keycode) {
}
}
- if (focused_index == row_count) {
- return;
- }
+ if (focused_index == row_count)
+ return false;
+
DCHECK_LT(focused_index, row_count);
// Nothing to do if the item which has the focus is not part of a group.
GroupRange group_range;
model_->GetGroupRangeForItem(focused_index, &group_range);
- if (group_range.length == 1) {
- return;
- }
+ if (group_range.length == 1)
+ return false;
// If the user pressed the UP key, then the focus should be set to the
// topmost element in the group. If the user pressed the DOWN key, the focus
// should be set to the bottommost element.
- if (virtual_keycode == VK_UP) {
+ if (virtual_keycode == base::VKEY_UP) {
SetFocusOnItem(group_range.start);
} else {
- DCHECK_EQ(virtual_keycode, VK_DOWN);
+ DCHECK_EQ(virtual_keycode, base::VKEY_DOWN);
SetFocusOnItem(group_range.start + group_range.length - 1);
}
+
+ return false;
}
void GroupTableView::PrepareForSort() {
diff --git a/views/controls/table/group_table_view.h b/views/controls/table/group_table_view.h
index 640776e..b137083 100644
--- a/views/controls/table/group_table_view.h
+++ b/views/controls/table/group_table_view.h
@@ -55,7 +55,7 @@ class GroupTableView : public TableView {
// keys), we must take action when an arrow key is pressed. The reason we
// need to process this message has to do with the manner in which the focus
// needs to be set on a group item when a group is selected.
- virtual void OnKeyDown(unsigned short virtual_keycode);
+ virtual bool OnKeyDown(base::KeyboardCode virtual_keycode);
// Overriden to make sure rows in the same group stay grouped together.
virtual int CompareRows(int model_row1, int model_row2);
diff --git a/views/controls/table/table_view.cc b/views/controls/table/table_view.cc
index 303d458..114019f 100644
--- a/views/controls/table/table_view.cc
+++ b/views/controls/table/table_view.cc
@@ -1057,15 +1057,6 @@ LRESULT TableView::OnNotify(int w_param, LPNMHDR hdr) {
OnDoubleClick();
break;
- // If we see a key down message, we need to invoke the OnKeyDown handler
- // in order to give our class (or any subclass) and opportunity to perform
- // a key down triggered action, if such action is necessary.
- case LVN_KEYDOWN: {
- NMLVKEYDOWN* key_down_message = reinterpret_cast<NMLVKEYDOWN*>(hdr);
- OnKeyDown(key_down_message->wVKey);
- break;
- }
-
case LVN_COLUMNCLICK: {
const TableColumn& column = GetColumnAtPosition(
reinterpret_cast<NMLISTVIEW*>(hdr)->iSubItem);
@@ -1459,10 +1450,11 @@ void TableView::OnSelectedStateChanged() {
}
}
-void TableView::OnKeyDown(unsigned short virtual_keycode) {
+bool TableView::OnKeyDown(base::KeyboardCode virtual_keycode) {
if (!ignore_listview_change_ && table_view_observer_) {
table_view_observer_->OnKeyDown(virtual_keycode);
}
+ return false; // Let the key event be processed as ususal.
}
void TableView::OnCheckedStateChanged(int model_row, bool is_checked) {
diff --git a/views/controls/table/table_view.h b/views/controls/table/table_view.h
index b8bda67..a1cce45d 100644
--- a/views/controls/table/table_view.h
+++ b/views/controls/table/table_view.h
@@ -16,6 +16,7 @@ typedef struct tagNMLVCUSTOMDRAW NMLVCUSTOMDRAW;
#include <vector>
#include "app/table_model_observer.h"
+#include "base/keyboard_codes.h"
#include "third_party/skia/include/core/SkColor.h"
#if defined(OS_WIN)
// TODO(port): remove the ifdef when native_control.h is ported.
@@ -250,9 +251,8 @@ class TableView : public NativeControl,
// Notification from the ListView that the user middle clicked the table.
virtual void OnMiddleClick();
- // Subclasses can implement this method if they need to be notified of a key
- // press event. Other wise, it appeals to table_view_observer_
- virtual void OnKeyDown(unsigned short virtual_keycode);
+ // Overridden from NativeControl. Notifies the observer.
+ virtual bool OnKeyDown(base::KeyboardCode virtual_keycode);
// Invoked to customize the colors or font at a particular cell. If you
// change the colors or font, return true. This is only invoked if
diff --git a/views/controls/table/table_view_observer.h b/views/controls/table/table_view_observer.h
index c88cb21..6b8bef2 100644
--- a/views/controls/table/table_view_observer.h
+++ b/views/controls/table/table_view_observer.h
@@ -24,7 +24,7 @@ class TableViewObserver {
virtual void OnMiddleClick() {}
// Optional method invoked when the user hits a key with the table in focus.
- virtual void OnKeyDown(unsigned short virtual_keycode) {}
+ virtual void OnKeyDown(base::KeyboardCode virtual_keycode) {}
// Invoked when the user presses the delete key.
virtual void OnTableViewDelete(TableView* table_view) {}
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 1872492..d027156 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -9,6 +9,7 @@
#include "app/win_util.h"
#include "base/clipboard.h"
#include "base/gfx/native_theme.h"
+#include "base/keyboard_codes.h"
#include "base/scoped_clipboard_writer.h"
#include "base/string_util.h"
#include "base/win_util.h"
@@ -252,13 +253,13 @@ bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id,
// anywhere so we need to check for them explicitly here.
switch (command_id) {
case IDS_APP_CUT:
- *accelerator = views::Accelerator(L'X', false, true, false);
+ *accelerator = views::Accelerator(base::VKEY_X, false, true, false);
return true;
case IDS_APP_COPY:
- *accelerator = views::Accelerator(L'C', false, true, false);
+ *accelerator = views::Accelerator(base::VKEY_C, false, true, false);
return true;
case IDS_APP_PASTE:
- *accelerator = views::Accelerator(L'V', false, true, false);
+ *accelerator = views::Accelerator(base::VKEY_V, false, true, false);
return true;
}
return container_view_->GetWidget()->GetAccelerator(command_id, accelerator);
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 368e7fd..bf12e42 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -14,6 +14,7 @@
#include "base/win_util.h"
#endif
+#include "base/keyboard_codes.h"
#include "base/string_util.h"
#include "views/controls/textfield/native_textfield_wrapper.h"
#include "views/widget/widget.h"
@@ -221,14 +222,14 @@ bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
#if defined(OS_WIN)
// TODO(hamaji): Figure out which keyboard combinations we need to add here,
// similar to LocationBarView::SkipDefaultKeyEventProcessing.
- const int c = e.GetCharacter();
- if (c == VK_BACK)
+ base::KeyboardCode key = e.GetKeyCode();
+ if (key == base::VKEY_BACK)
return true; // We'll handle BackSpace ourselves.
// We don't translate accelerators for ALT + NumPad digit, they are used for
// entering special characters. We do translate alt-home.
- if (e.IsAltDown() && (c != VK_HOME) &&
- win_util::IsNumPadDigit(c, e.IsExtendedKey()))
+ if (e.IsAltDown() && (key != base::VKEY_HOME) &&
+ win_util::IsNumPadDigit(key, e.IsExtendedKey()))
return true;
#endif
return false;
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index 196e773..c84ef8b 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -12,6 +12,7 @@
#include "app/l10n_util_win.h"
#include "app/resource_bundle.h"
#include "base/gfx/point.h"
+#include "base/keyboard_codes.h"
#include "base/stl_util-inl.h"
#include "base/win_util.h"
#include "grit/app_resources.h"
@@ -459,7 +460,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) {
return 0;
}
-bool TreeView::OnKeyDown(int virtual_key_code) {
+bool TreeView::OnKeyDown(base::KeyboardCode virtual_key_code) {
if (virtual_key_code == VK_F2) {
if (!GetEditingNode()) {
TreeModelNode* selected_node = GetSelectedNode();
@@ -467,10 +468,10 @@ bool TreeView::OnKeyDown(int virtual_key_code) {
StartEditing(selected_node);
}
return true;
- } else if (virtual_key_code == VK_RETURN && !process_enter_) {
+ } else if (virtual_key_code == base::VKEY_RETURN && !process_enter_) {
Widget* widget = GetWidget();
DCHECK(widget);
- Accelerator accelerator(Accelerator(static_cast<int>(virtual_key_code),
+ Accelerator accelerator(Accelerator(virtual_key_code,
win_util::IsShiftPressed(),
win_util::IsCtrlPressed(),
win_util::IsAltPressed()));
diff --git a/views/controls/tree/tree_view.h b/views/controls/tree/tree_view.h
index 72667bf..0011835 100644
--- a/views/controls/tree/tree_view.h
+++ b/views/controls/tree/tree_view.h
@@ -12,6 +12,7 @@
#include "app/tree_model.h"
#include "base/basictypes.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "views/controls/native_control.h"
@@ -159,7 +160,7 @@ class TreeView : public NativeControl, TreeModelObserver {
// We pay attention to key down for two reasons: to circumvent VK_ENTER from
// toggling the expaned state when processes_enter_ is false, and to have F2
// start editting.
- virtual bool OnKeyDown(int virtual_key_code);
+ virtual bool OnKeyDown(base::KeyboardCode virtual_key_code);
virtual void OnContextMenu(const POINT& location);