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

Side by Side Diff: chrome/browser/views/toolbar_view.cc

Issue 15098: Enables restoring of keyboard focus to the the toolbar button that last had f... (Closed) Base URL: svn://chrome-svn/chrome/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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/toolbar_view.h" 5 #include "chrome/browser/views/toolbar_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 sz = page_menu_->GetPreferredSize(); 336 sz = page_menu_->GetPreferredSize();
337 page_menu_->SetBounds(page_x, kControlVertOffset, sz.width(), 337 page_menu_->SetBounds(page_x, kControlVertOffset, sz.width(),
338 go_->height()); 338 go_->height());
339 sz = app_menu_->GetPreferredSize(); 339 sz = app_menu_->GetPreferredSize();
340 app_menu_->SetBounds(page_menu_->x() + page_menu_->width(), 340 app_menu_->SetBounds(page_menu_->x() + page_menu_->width(),
341 page_menu_->y(), sz.width(), go_->height()); 341 page_menu_->y(), sz.width(), go_->height());
342 } 342 }
343 } 343 }
344 344
345 void BrowserToolbarView::DidGainFocus() { 345 void BrowserToolbarView::DidGainFocus() {
346 // Find first accessible child (-1 for start search at parent). 346 // Check to see if MSAA focus should be restored to previously focused button,
347 int first_acc_child = GetNextAccessibleViewIndex(-1, false); 347 // and if button is an enabled, visibled child of toolbar.
348 if (!acc_focused_view() ||
349 (acc_focused_view()->GetParent()->GetID() != VIEW_ID_TOOLBAR) ||
350 !acc_focused_view()->IsEnabled() ||
351 !acc_focused_view()->IsVisible()) {
352 // Find first accessible child (-1 to start search at parent).
353 int first_acc_child = GetNextAccessibleViewIndex(-1, false);
348 354
349 // No buttons enabled or visible. 355 // No buttons enabled or visible.
350 if (first_acc_child == -1) 356 if (first_acc_child == -1)
351 return; 357 return;
352 358
353 acc_focused_view_ = GetChildViewAt(first_acc_child); 359 set_acc_focused_view(GetChildViewAt(first_acc_child));
360 }
354 361
355 // Default focus is on the toolbar. 362 // Default focus is on the toolbar.
356 int view_index = VIEW_ID_TOOLBAR; 363 int view_index = VIEW_ID_TOOLBAR;
357 364
358 // Set hot-tracking for child, and update focused_view for MSAA focus event. 365 // Set hot-tracking for child, and update focused_view for MSAA focus event.
359 if (acc_focused_view_) { 366 if (acc_focused_view()) {
360 acc_focused_view_->SetHotTracked(true); 367 acc_focused_view()->SetHotTracked(true);
361 368
362 // Show the tooltip for the view that got the focus. 369 // Show the tooltip for the view that got the focus.
363 if (GetWidget()->GetTooltipManager()) 370 if (GetWidget()->GetTooltipManager())
364 GetWidget()->GetTooltipManager()->ShowKeyboardTooltip(acc_focused_view_); 371 GetWidget()->GetTooltipManager()->ShowKeyboardTooltip(acc_focused_view_);
365 372
366 // Update focused_view with MSAA-adjusted child id. 373 // Update focused_view with MSAA-adjusted child id.
367 view_index = acc_focused_view_->GetID(); 374 view_index = acc_focused_view()->GetID();
368 } 375 }
369 376
370 HWND hwnd = GetWidget()->GetHWND(); 377 HWND hwnd = GetWidget()->GetHWND();
371 378
372 // Notify Access Technology that there was a change in keyboard focus. 379 // Notify Access Technology that there was a change in keyboard focus.
373 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT, 380 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT,
374 static_cast<LONG>(view_index)); 381 static_cast<LONG>(view_index));
375 } 382 }
376 383
377 void BrowserToolbarView::WillLoseFocus() { 384 void BrowserToolbarView::WillLoseFocus() {
378 // Resetting focus state. 385 // Resetting focus state.
379 acc_focused_view_->SetHotTracked(false); 386 acc_focused_view_->SetHotTracked(false);
380 // Any tooltips that are active should be hidden when toolbar loses focus. 387 // Any tooltips that are active should be hidden when toolbar loses focus.
381 if (GetWidget() && GetWidget()->GetTooltipManager()) 388 if (GetWidget() && GetWidget()->GetTooltipManager())
382 GetWidget()->GetTooltipManager()->HideKeyboardTooltip(); 389 GetWidget()->GetTooltipManager()->HideKeyboardTooltip();
383 acc_focused_view_ = NULL;
384 } 390 }
jcampan 2008/12/20 02:20:11 I think I saw a case where the button was still sh
385 391
386 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) { 392 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) {
387 // Paranoia check, button should be initialized upon toolbar gaining focus. 393 // Paranoia check, button should be initialized upon toolbar gaining focus.
388 if (!acc_focused_view_) 394 if (!acc_focused_view_)
389 return false; 395 return false;
390 396
391 int focused_view = GetChildIndex(acc_focused_view_); 397 int focused_view = GetChildIndex(acc_focused_view_);
392 int next_view = focused_view; 398 int next_view = focused_view;
393 399
394 switch (e.GetCharacter()) { 400 switch (e.GetCharacter()) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 *accel = views::Accelerator(L'C', false, true, false); 773 *accel = views::Accelerator(L'C', false, true, false);
768 return true; 774 return true;
769 case IDC_PASTE: 775 case IDC_PASTE:
770 *accel = views::Accelerator(L'V', false, true, false); 776 *accel = views::Accelerator(L'V', false, true, false);
771 return true; 777 return true;
772 } 778 }
773 // Else, we retrieve the accelerator information from the frame. 779 // Else, we retrieve the accelerator information from the frame.
774 return GetWidget()->GetAccelerator(id, accel); 780 return GetWidget()->GetAccelerator(id, accel);
775 } 781 }
776 782
OLDNEW
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698