This is the same as \helpref{Refresh}{wxwindowrefresh} but has a nicer syntax.
+\membersection{wxWindow::RegisterHotKey}\label{wxwindowregisterhotkey}
+
+\func{bool}{RegisterHotKey}{\param{int}{ hotkeyId}, \param{int}{ modifiers}, \param{int}{ virtualKeyCode}}
+
+Registers a system wide hotkey. Every time the user presses the hotkey registered here, this window
+will receive a hotkey event. It will receive the event even if the application is in the background
+and does not have the input focus because the user is working with some other application.
+
+\wxheading{Parameters}
+
+\docparam{hotkeyId}{Numeric identifier of the hotkey. For applications this must be between 0 and 0xBFFF. If
+this function is called from a shared DLL, it must be a system wide unique identifier between 0xC000 and 0xFFFF.
+This is a MSW specific detail.}
+
+\docparam{modifiers}{A bitwise combination of {\tt wxMOD\_SHIFT}, {\tt wxMOD\_CONTROL}, {\tt wxMOD\_ALT}
+or {\tt wxMOD\_WIN} specifying the modifier keys that have to be pressed along with the key.}
+
+\docparam{virtualKeyCode}{The virtual key code of the hotkey.}
+
+\wxheading{Return value}
+
+{\tt true} if the hotkey was registered successfully. {\tt false} if some other application already registered a
+hotkey with this modifier/virtualKeyCode combination.
+
+\wxheading{Remarks}
+
+Use EVT\_HOTKEY(hotkeyId, fnc) in the event table to capture the event.
+This function is currently only implemented under MSW.
+
+\wxheading{See also}
+
+\helpref{wxWindow::UnregisterHotKey}{wxwindowunregisterhotkey}
+
\membersection{wxWindow::ReleaseMouse}\label{wxwindowreleasemouse}
\func{virtual void}{ReleaseMouse}{\void}
\helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow},\rtfsp
\helpref{wxValidator}{wxvalidator}, \helpref{wxWindow::Validate}{wxwindowvalidate}
+\membersection{wxWindow::UnregisterHotKey}\label{wxwindowunregisterhotkey}
+
+\func{bool}{UnregisterHotKey}{\param{int}{ hotkeyId}}
+
+Unregisters a system wide hotkey.
+
+\wxheading{Parameters}
+
+\docparam{hotkeyId}{Numeric identifier of the hotkey. Must be the same id that was passed to RegisterHotKey.}
+
+\wxheading{Return value}
+
+{\tt true} if the hotkey was unregistered successfully, {\tt false} if the id was invalid.
+
+\wxheading{Remarks}
+
+This function is currently only implemented under MSW.
+
+\wxheading{See also}
+
+\helpref{wxWindow::RegisterHotKey}{wxwindowregisterhotkey}
+
\membersection{wxWindow::Update}\label{wxwindowupdate}
\func{virtual void}{Update}{\void}
- In doc/view file selector, document type is selected by
extension, not the type selected in the (Windows) file selector.
+- Add wxUSE_HOTKEY and any other missing options to configure.
+
WXK_WINDOWS_MENU
};
+#if wxUSE_HOTKEY
+enum wxHotkeyModifier
+{
+ wxMOD_NONE = 0,
+ wxMOD_ALT = 1,
+ wxMOD_CONTROL = 2,
+ wxMOD_SHIFT = 4,
+ wxMOD_WIN = 8
+};
+#endif
+
// Mapping modes (same values as used by Windows, don't change)
enum
{
DECLARE_EVENT_TYPE(wxEVT_NAVIGATION_KEY, 214)
DECLARE_EVENT_TYPE(wxEVT_KEY_DOWN, 215)
DECLARE_EVENT_TYPE(wxEVT_KEY_UP, 216)
-
+#if wxUSE_HOTKEY
+ DECLARE_EVENT_TYPE(wxEVT_HOTKEY, 217)
+#endif
// Set cursor event
DECLARE_EVENT_TYPE(wxEVT_SET_CURSOR, 230)
wxEVT_CHAR_HOOK
wxEVT_KEY_DOWN
wxEVT_KEY_UP
+ wxEVT_HOTKEY
*/
class WXDLLIMPEXP_CORE wxKeyEvent : public wxEvent
#define EVT_CHAR(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHAR, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
#define EVT_KEY_DOWN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_DOWN, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
#define EVT_KEY_UP(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_KEY_UP, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
+#if wxUSE_HOTKEY
+#define EVT_HOTKEY(id, func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_HOTKEY, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, (wxObject *) NULL ),
+#endif
#define EVT_CHAR_HOOK(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHAR_HOOK, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCharEventFunction) & func, NULL ),
#define EVT_MENU_OPEN(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_OPEN, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
#define EVT_MENU_CLOSE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENU_CLOSE, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMenuEventFunction) & func, (wxObject *) NULL ),
// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar)
#define wxUSE_ACCEL 1
+// Hotkey support (currently Windows only)
+#define wxUSE_HOTKEY 1
+
// Use wxCaret: a class implementing a "cursor" in a text control (called caret
// under Windows).
//
wxWindow* GetWindowChild(wxWindowID id);
#endif // __WXUNIVERSAL__
+#if wxUSE_ACCEL
+ // install and deinstall a system wide hotkey
+ virtual bool RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode);
+ virtual bool UnregisterHotKey(int hotkeyId);
+#endif
+
// implementation from now on
// --------------------------
bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = FALSE);
bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
+#if wxUSE_ACCEL
+ bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam);
+#endif
#ifdef __WIN32__
int HandleMenuChar(int chAccel, WXLPARAM lParam);
#endif
{ m_acceleratorTable = accel; }
wxAcceleratorTable *GetAcceleratorTable()
{ return &m_acceleratorTable; }
+
+ // install and deinstall a system wide hotkey
+ virtual bool RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode);
+ virtual bool UnregisterHotKey(int hotkeyId);
+
#endif // wxUSE_ACCEL
// dialog units translations
DEFINE_EVENT_TYPE(wxEVT_NAVIGATION_KEY)
DEFINE_EVENT_TYPE(wxEVT_KEY_DOWN)
DEFINE_EVENT_TYPE(wxEVT_KEY_UP)
+#if wxUSE_HOTKEY
+DEFINE_EVENT_TYPE(wxEVT_HOTKEY)
+#endif
// Set cursor event
DEFINE_EVENT_TYPE(wxEVT_SET_CURSOR)
GetCapture());
}
+#if wxUSE_HOTKEY
+bool wxWindowBase::RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode)
+{
+ // not implemented
+ return false;
+}
+
+bool wxWindowBase::UnregisterHotKey(int hotkeyId)
+{
+ // not implemented
+ return false;
+}
+#endif
void wxWindowBase::SendDestroyEvent()
{
}
break;
+#if wxUSE_HOTKEY
+ case WM_HOTKEY:
+ processed = HandleHotKey((WORD)wParam, lParam);
+ break;
+#endif
+
case WM_HSCROLL:
case WM_VSCROLL:
{
case 0x030F: return "WM_QUERYNEWPALETTE";
case 0x0310: return "WM_PALETTEISCHANGING";
case 0x0311: return "WM_PALETTECHANGED";
+#if wxUSE_HOTKEY
+ case 0x0312: return "WM_HOTKEY";
+#endif
// common controls messages - although they're not strictly speaking
// standard, it's nice to decode them nevertheless
return wxPoint(pt.x, pt.y);
}
+#if wxUSE_HOTKEY
+bool wxWindowMSW::RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode)
+{
+ UINT win_modifiers=0;
+ if (modifiers & wxMOD_ALT)
+ win_modifiers|=MOD_ALT;
+ if (modifiers & wxMOD_SHIFT)
+ win_modifiers|=MOD_SHIFT;
+ if (modifiers & wxMOD_CONTROL)
+ win_modifiers|=MOD_CONTROL;
+ if (modifiers & wxMOD_WIN)
+ win_modifiers|=MOD_WIN;
+
+ return ::RegisterHotKey(GetHwnd(), hotkeyId, win_modifiers, virtualKeyCode)!=FALSE;
+}
+
+bool wxWindowMSW::UnregisterHotKey(int hotkeyId)
+{
+ return ::UnregisterHotKey(GetHwnd(), hotkeyId)!=FALSE;
+}
+
+bool wxWindowMSW::HandleHotKey(WXWPARAM wParam, WXLPARAM lParam)
+{
+ int hotkeyId=wParam;
+ int virtualKey=HIWORD(lParam);
+ int win_modifiers=LOWORD(lParam);
+ /*
+ wxHotkeyModifier modifiers=wxMOD_NONE;
+ if (win_modifiers & MOD_ALT)
+ modifiers|=wxMOD_ALT;
+ if (win_modifiers & MOD_SHIFT)
+ modifiers|=wxMOD_SHIFT;
+ if (win_modifiers & MOD_CONTROL)
+ modifiers|=wxMOD_CONTROL;
+ if (win_modifiers & MOD_WIN)
+ modifiers|=wxMOD_WIN;
+*/
+ wxKeyEvent event(CreateKeyEvent(wxEVT_HOTKEY, virtualKey, wParam, lParam));
+ event.SetId(hotkeyId);
+ event.m_shiftDown = (win_modifiers & MOD_SHIFT) != 0;
+ event.m_controlDown = (win_modifiers & MOD_CONTROL) != 0;
+ event.m_altDown = (win_modifiers & MOD_ALT) != 0;
+ event.m_metaDown = (win_modifiers & MOD_WIN) != 0;
+ return GetEventHandler()->ProcessEvent(event);
+}
+#endif
+