summaryrefslogtreecommitdiffstats
path: root/views/controls/table
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:18:58 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:18:58 +0000
commitd766882c913b272cc2db478d7640a317d838ebad (patch)
tree99424c7a994d0d771bd4c3bdf2b196042b937b62 /views/controls/table
parenteb75208190b35bedd144e102ea5cc826358bbbfd (diff)
downloadchromium_src-d766882c913b272cc2db478d7640a317d838ebad.zip
chromium_src-d766882c913b272cc2db478d7640a317d838ebad.tar.gz
chromium_src-d766882c913b272cc2db478d7640a317d838ebad.tar.bz2
Changing the KeyboardEvent to use a KeyboardCode instead of a w_char. Led to several places where I had to switch from VK_ to VKEY_.
Also cleaned-up the table view OnKeyDown method. Since TableView is a NativeControl it can use the NativeControl::OnKeyDown directly. BUG=None TEST=Make sure short-cuts works as expected, especially in the omnibox. Review URL: http://codereview.chromium.org/248010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/table')
-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
5 files changed, 20 insertions, 27 deletions
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) {}