summaryrefslogtreecommitdiffstats
path: root/chrome/views/chrome_menu.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-22 22:23:43 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-22 22:23:43 +0000
commit20ea3526d1b851a5594d7d05a472e83757df034d (patch)
tree4a22d472d541abccbd27242b4c94d45de1fdc366 /chrome/views/chrome_menu.cc
parent393c02e5a411707d7a5e15432ce7328386292f5a (diff)
downloadchromium_src-20ea3526d1b851a5594d7d05a472e83757df034d.zip
chromium_src-20ea3526d1b851a5594d7d05a472e83757df034d.tar.gz
chromium_src-20ea3526d1b851a5594d7d05a472e83757df034d.tar.bz2
I'm going to try and land this again. This is exactly the same change as you reviewed earlier.
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/4021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2458 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/chrome_menu.cc')
-rw-r--r--chrome/views/chrome_menu.cc28
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() {