Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1954)

Unified Diff: chrome/browser/views/download_tab_view.cc

Issue 13278: Context menu key should work on download page... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/download_tab_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/download_tab_view.cc
===================================================================
--- chrome/browser/views/download_tab_view.cc (revision 6493)
+++ chrome/browser/views/download_tab_view.cc (working copy)
@@ -184,6 +184,10 @@
show_->SetController(this);
show_->SetFont(font);
AddChildView(show_);
+
+ SetFocusable(true);
+
+ SetContextMenuController(this);
}
DownloadItemTabView::~DownloadItemTabView() {
@@ -689,6 +693,25 @@
}
}
+bool DownloadItemTabView::CanProcessTabKeyEvents() {
+ return true;
+}
+
+bool DownloadItemTabView::OnKeyPressed(const views::KeyEvent& event) {
+ // When you press DOWN or TAB select the next item in the downloads, otherwise
+ // when you press SHIFT+TAB or UP select the previous item. Note that the
+ // first download index is always in reverse, hence last index.
+ if (event.GetCharacter() == VK_DOWN || (GetKeyState(VK_SHIFT) >= 0 &&
+ event.GetCharacter() == VK_TAB)) {
+ parent_->SelectItemAtIndex(parent_->selected_index() - 1);
+ }
+ else if (event.GetCharacter() == VK_UP || (GetKeyState(VK_SHIFT) < 0 &&
+ event.GetCharacter() == VK_TAB)) {
+ parent_->SelectItemAtIndex(parent_->selected_index() + 1);
+ }
+ return true;
+}
+
bool DownloadItemTabView::OnMousePressed(const views::MouseEvent& event) {
gfx::Point point(event.location());
@@ -707,6 +730,11 @@
gfx::Rect mirrored_rect(select_rect);
select_rect.set_x(MirroredLeftPointForRect(mirrored_rect));
if (select_rect.Contains(point)) {
+ // Request Focus if not present to allow keyboard events to work and context
+ // menu to function properly.
+ if (!HasFocus())
+ RequestFocus();
+
parent_->ItemBecameSelected(model_);
// Don't show the right-click menu if we are prompting the user for a
@@ -731,13 +759,13 @@
model_->safety_state() == DownloadItem::DANGEROUS)
return false;
- CPoint point(event.x(), event.y());
+ gfx::Point point(event.x(), event.y());
// In order to make sure drag and drop works as expected when the UI is
// mirrored, we can either flip the mouse X coordinate or flip the X position
// of the drag rectangle. Flipping the mouse X coordinate is easier.
- point.x = MirroredXCoordinateInsideView(point.x);
- CRect drag_rect(kDownloadIconOffset -
+ point.set_x(MirroredXCoordinateInsideView(point.x()));
+ gfx::Rect drag_rect(kDownloadIconOffset -
parent_->big_icon_offset(),
0,
kDownloadIconOffset -
@@ -746,7 +774,7 @@
kFilenameSize,
parent_->big_icon_size());
- if (drag_rect.PtInRect(point)) {
+ if (drag_rect.Contains(point)) {
SkBitmap* icon = parent_->LookupIcon(model_);
if (icon)
download_util::DragDownload(model_, icon);
@@ -755,6 +783,18 @@
return true;
}
+void DownloadItemTabView::ShowContextMenu(View* source,
+ int x,
+ int y,
+ bool is_mouse_gesture) {
+ // Only show context menu when an item has been selected.
+ if (parent_->selected_index() != -1) {
+ gfx::Point location (x, y);
+ download_util::DownloadDestinationContextMenu menu(
+ model_, GetWidget()->GetHWND(), location.ToPOINT());
+ }
+}
+
void DownloadItemTabView::LinkActivated(views::Link* source, int event_flags) {
// There are several links in our view that could have been clicked:
if (source == file_name_) {
@@ -1176,6 +1216,13 @@
return false;
}
+void DownloadTabView::SelectItemAtIndex(int index) {
+ if (selected_index() == -1)
+ ItemBecameSelected(downloads_[total_downloads() - 1]);
+ else if (index >= 0 && index < total_downloads())
+ ItemBecameSelected(downloads_[index]);
+}
+
void DownloadTabView::SchedulePaintForViewAtIndex(int index) {
int y = GetYPositionForIndex(index);
SchedulePaint(0, y, width(), big_icon_size_);
« no previous file with comments | « chrome/browser/views/download_tab_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698