// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
// Modified by:
// Created: 2010-03-06
-// RCS-ID: $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $
+// RCS-ID: $Id$
// Copyright: (c) Kevin Ollivier
// (c) 2010 Steven Lamerton
// (c) 2010 Vadim Zeitlin
return pos;
}
-bool SendCharCode(CGKeyCode keycode, bool isDown)
-{
- wxCFRef<CGEventRef>
- event(CGEventCreateKeyboardEvent(NULL, keycode, isDown));
- if ( !event )
- return false;
-
- CGEventPost(kCGHIDEventTap, event);
- return true;
-}
-
CGKeyCode wxCharCodeWXToOSX(wxKeyCode code)
{
CGKeyCode keycode;
case WXK_NUMPAD_DECIMAL: keycode = kVK_ANSI_KeypadDecimal; break;
case WXK_NUMPAD_DIVIDE: keycode = kVK_ANSI_KeypadDivide; break;
- default: wxLogDebug( "Unrecognised keycode %d", code );
+ default:
+ wxLogDebug( "Unrecognised keycode %d", code );
+ keycode = -1;
}
return keycode;
return true;
}
-bool wxUIActionSimulator::DoKey(int keycode, int modifiers, bool isDown)
+bool
+wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
{
- if (isDown)
- {
- if (modifiers & wxMOD_SHIFT)
- SendCharCode(kVK_Shift, true);
- if (modifiers & wxMOD_ALT)
- SendCharCode(kVK_Option, true);
- if (modifiers & wxMOD_CMD)
- SendCharCode(kVK_Command, true);
- }
-
CGKeyCode cgcode = wxCharCodeWXToOSX((wxKeyCode)keycode);
- if ( !SendCharCode(cgcode, isDown) )
- return false;
- if(!isDown)
- {
- if (modifiers & wxMOD_SHIFT)
- SendCharCode(kVK_Shift, false);
- if (modifiers & wxMOD_ALT)
- SendCharCode(kVK_Option, false);
- if (modifiers & wxMOD_CMD)
- SendCharCode(kVK_Command, false);
- }
+ wxCFRef<CGEventRef>
+ event(CGEventCreateKeyboardEvent(NULL, cgcode, isDown));
+ if ( !event )
+ return false;
+ CGEventPost(kCGHIDEventTap, event);
return true;
}