[wxMac CVS HEAD] wxAccelerator Control vs Command?
Ryan Wilcox
rwilcox at wilcoxd.com
Sun Aug 27 19:08:55 PDT 2006
Hi all,
Today I was playing with wxAcceleratorTable. The wxBook(p.180) says:
"Note that on OS X, a shortcut specification involving Ctrl will actually use the Command key"
I tested this assertion out, and proved it false! (At least with CVS head, updated yesterday 08-26-06) Apply the following patch to the minimal sample...
_______________________________
Index: minimal.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/samples/minimal/minimal.cpp,v
retrieving revision 1.71
diff -u -r1.71 minimal.cpp
--- minimal.cpp 2006/06/29 13:47:45 1.71
+++ minimal.cpp 2006/08/28 01:58:56
@@ -148,6 +148,13 @@
// set the frame icon
SetIcon(wxICON(sample));
+ wxAcceleratorEntry entries[1];
+
+ entries[0].Set(wxACCEL_CTRL, (int)'N', Minimal_About);
+
+ wxAcceleratorTable accel(1, entries);
+ SetAcceleratorTable(accel);
+
#if wxUSE_MENUS
// create a menu bar
wxMenu *fileMenu = new wxMenu;
_______________________________
Part of me expected this to work, since control -> command translations happens properly in other situations (like menus handling) (and probably should happen correctly in this situation too, I'm thinking)
For interest the relevant portion of GetCommand() in src/mac/carbon/accel.cpp reads:
wxAcceleratorEntry *entry = node->GetData();
if ((event.m_keyCode == entry->GetKeyCode()) &&
(((entry->GetFlags() & wxACCEL_CTRL) == 0) ||
event.ControlDown()) &&
(((entry->GetFlags() & wxACCEL_SHIFT) == 0) ||
event.ShiftDown()) &&
(((entry->GetFlags() & wxACCEL_ALT) == 0) ||
event.AltDown() || event.MetaDown()))
{
return entry->GetCommand();
}
FWIW, replacing the wxACCEL_CTRL with wxACCEL_ALT in minimal.cpp allows me to press Command-N and get the Minimal About Dialog.
I'm guessing that the Meta check should be moved up with the control check. Right?
Hope this helps,
_Ryan Wilcox
--
Wilcox Development Solutions: <http://www.wilcoxd.com>
Toolsmiths for the Internet Age PGP: 0x2F4E9C31
More information about the wx-users
mailing list