diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-22 17:21:04 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-22 17:21:04 +0000 |
commit | b1b945e8f3586a8d08acc9e7d29b4efe99606373 (patch) | |
tree | 6d9a280621bb7d55b641b787f887b31503d91dd6 /chrome/views/chrome_menu.cc | |
parent | 0f8a6b4de386b469859f6cd12c0ba091453c9a4d (diff) | |
download | chromium_src-b1b945e8f3586a8d08acc9e7d29b4efe99606373.zip chromium_src-b1b945e8f3586a8d08acc9e7d29b4efe99606373.tar.gz chromium_src-b1b945e8f3586a8d08acc9e7d29b4efe99606373.tar.bz2 |
Fixes mnemonic bug in chrome menus. After this change you can indicate
whether menus have mnemonics. Mnemonics are shown if the menus have
mnemonics, and the OS says we should show them.
BUG=1355952
TEST=add a bookmark and change the title to &foo. Move the bookmark to
a folder, click on the folder and make sure the title shows the &.
Review URL: http://codereview.chromium.org/4002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/chrome_menu.cc')
-rw-r--r-- | chrome/views/chrome_menu.cc | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index 360f8c4..537503f 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -103,6 +103,9 @@ static const int kScrollTimerMS = 30; // Preferred height of menu items. Reset every time a menu is run. static int pref_menu_height; +// Are mnemonics shown? This is updated before the menus are shown. +static bool show_mnemonics; + using gfx::NativeTheme; namespace ChromeViews { @@ -1069,8 +1072,8 @@ MenuItemView::~MenuItemView() { void MenuItemView::RunMenuAt(HWND parent, const gfx::Rect& bounds, AnchorPosition anchor, - bool show_mnemonics) { - PrepareForRun(show_mnemonics); + bool has_mnemonics) { + PrepareForRun(has_mnemonics); int mouse_event_flags; @@ -1190,6 +1193,9 @@ MenuItemView* MenuItemView::GetRootMenuItem() { } wchar_t MenuItemView::GetMnemonic() { + if (!has_mnemonics_) + return 0; + const std::wstring& title = GetTitle(); size_t index = 0; do { @@ -1285,7 +1291,7 @@ void MenuItemView::DropMenuClosed(bool notify_delegate) { // WARNING: its possible the delegate deleted us at this point. } -void MenuItemView::PrepareForRun(bool show_mnemonics) { +void MenuItemView::PrepareForRun(bool has_mnemonics) { // Currently we only support showing the root. DCHECK(!parent_menu_item_); @@ -1297,11 +1303,16 @@ void MenuItemView::PrepareForRun(bool show_mnemonics) { canceled_ = false; - show_mnemonics_ = show_mnemonics; + has_mnemonics_ = has_mnemonics; AddEmptyMenus(); UpdateMenuPartSizes(); + + BOOL show_cues; + show_mnemonics = + (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && + show_cues == TRUE); } int MenuItemView::GetDrawStringFlags() { @@ -1311,8 +1322,13 @@ int MenuItemView::GetDrawStringFlags() { else flags |= ChromeCanvas::TEXT_ALIGN_LEFT; - return flags | - (show_mnemonics_ ? ChromeCanvas::SHOW_PREFIX : ChromeCanvas::HIDE_PREFIX); + if (has_mnemonics_) { + if (show_mnemonics) + flags |= ChromeCanvas::SHOW_PREFIX; + else + flags |= ChromeCanvas::HIDE_PREFIX; + } + return flags; } void MenuItemView::AddEmptyMenus() { |