Added wxGetMouseState which returns the current state of the mouse.
Returns an instance of a wxMouseState object that contains the current position of the mouse pointer in screen coordinants, as well as boolean values indicating the up/down status of the mouse buttons and the modifier keys. Implemented for wxMSW, wxGTK and wxMac. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -51,6 +51,7 @@ All (GUI):
|
|||||||
- Implemented <sub> and <sup> handling in wxHTML (based on patch
|
- Implemented <sub> and <sup> handling in wxHTML (based on patch
|
||||||
by Sandro Sigala)
|
by Sandro Sigala)
|
||||||
- Added caption parameter to wxGetFontFromUser and wxGetColourFromUser.
|
- Added caption parameter to wxGetFontFromUser and wxGetColourFromUser.
|
||||||
|
- Added wxGetMouseState function.
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -128,6 +128,7 @@ the corresponding topic.
|
|||||||
\helpref{wxGetLocalTimeMillis}{wxgetlocaltimemillis}\\
|
\helpref{wxGetLocalTimeMillis}{wxgetlocaltimemillis}\\
|
||||||
\helpref{wxGetLocalTime}{wxgetlocaltime}\\
|
\helpref{wxGetLocalTime}{wxgetlocaltime}\\
|
||||||
\helpref{wxGetMousePosition}{wxgetmouseposition}\\
|
\helpref{wxGetMousePosition}{wxgetmouseposition}\\
|
||||||
|
\helpref{wxGetMouseState}{wxgetmousestate}\\
|
||||||
\helpref{wxGetMultipleChoices}{wxgetmultiplechoices}\\
|
\helpref{wxGetMultipleChoices}{wxgetmultiplechoices}\\
|
||||||
\helpref{wxGetMultipleChoice}{wxgetmultiplechoice}\\
|
\helpref{wxGetMultipleChoice}{wxgetmultiplechoice}\\
|
||||||
\helpref{wxGetNumberFromUser}{wxgetnumberfromuser}\\
|
\helpref{wxGetNumberFromUser}{wxgetnumberfromuser}\\
|
||||||
@@ -3009,6 +3010,55 @@ Returns the mouse position in screen coordinates.
|
|||||||
<wx/utils.h>
|
<wx/utils.h>
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{::wxGetMouseState}\label{wxgetmousestate}
|
||||||
|
|
||||||
|
\func{wxMouseState}{wxGetMouseState}{\void}
|
||||||
|
|
||||||
|
Returns the current state of the mouse. Returns a wxMouseState
|
||||||
|
instance that contains the current position of the mouse pointer in
|
||||||
|
screen coordinants, as well as boolean values indicating the up/down
|
||||||
|
status of the mouse buttons and the modifier keys.
|
||||||
|
|
||||||
|
\wxheading{Include files}
|
||||||
|
|
||||||
|
<wx/utils.h>
|
||||||
|
|
||||||
|
wxMouseState has the following interface:
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
class wxMouseState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxMouseState();
|
||||||
|
|
||||||
|
wxCoord GetX();
|
||||||
|
wxCoord GetY();
|
||||||
|
|
||||||
|
bool LeftDown();
|
||||||
|
bool MiddleDown();
|
||||||
|
bool RightDown();
|
||||||
|
|
||||||
|
bool ControlDown();
|
||||||
|
bool ShiftDown();
|
||||||
|
bool AltDown();
|
||||||
|
bool MetaDown();
|
||||||
|
bool CmdDown();
|
||||||
|
|
||||||
|
void SetX(wxCoord x);
|
||||||
|
void SetY(wxCoord y);
|
||||||
|
|
||||||
|
void SetLeftDown(bool down);
|
||||||
|
void SetMiddleDown(bool down);
|
||||||
|
void SetRightDown(bool down);
|
||||||
|
|
||||||
|
void SetControlDown(bool down);
|
||||||
|
void SetShiftDown(bool down);
|
||||||
|
void SetAltDown(bool down);
|
||||||
|
void SetMetaDown(bool down);
|
||||||
|
};
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
\membersection{::wxGetResource}\label{wxgetresource}
|
\membersection{::wxGetResource}\label{wxgetresource}
|
||||||
|
|
||||||
\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
|
\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
|
||||||
|
@@ -114,6 +114,70 @@ WXDLLEXPORT bool wxGetKeyState(wxKeyCode key);
|
|||||||
// in wxMSW.
|
// in wxMSW.
|
||||||
WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag );
|
WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag );
|
||||||
|
|
||||||
|
|
||||||
|
// wxMouseState is used to hold information about button and modifier state
|
||||||
|
// and is what is returned from wxGetMouseState.
|
||||||
|
class WXDLLEXPORT wxMouseState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxMouseState()
|
||||||
|
: m_x(0), m_y(0),
|
||||||
|
m_leftDown(false), m_middleDown(false), m_rightDown(false),
|
||||||
|
m_controlDown(false), m_shiftDown(false), m_altDown(false),
|
||||||
|
m_metaDown(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
wxCoord GetX() { return m_x; }
|
||||||
|
wxCoord GetY() { return m_y; }
|
||||||
|
|
||||||
|
bool LeftDown() { return m_leftDown; }
|
||||||
|
bool MiddleDown() { return m_middleDown; }
|
||||||
|
bool RightDown() { return m_rightDown; }
|
||||||
|
|
||||||
|
bool ControlDown() { return m_controlDown; }
|
||||||
|
bool ShiftDown() { return m_shiftDown; }
|
||||||
|
bool AltDown() { return m_altDown; }
|
||||||
|
bool MetaDown() { return m_metaDown; }
|
||||||
|
bool CmdDown()
|
||||||
|
{
|
||||||
|
#if defined(__WXMAC__) || defined(__WXCOCOA__)
|
||||||
|
return MetaDown();
|
||||||
|
#else
|
||||||
|
return ControlDown();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetX(wxCoord x) { m_x = x; }
|
||||||
|
void SetY(wxCoord y) { m_y = y; }
|
||||||
|
|
||||||
|
void SetLeftDown(bool down) { m_leftDown = down; }
|
||||||
|
void SetMiddleDown(bool down) { m_middleDown = down; }
|
||||||
|
void SetRightDown(bool down) { m_rightDown = down; }
|
||||||
|
|
||||||
|
void SetControlDown(bool down) { m_controlDown = down; }
|
||||||
|
void SetShiftDown(bool down) { m_shiftDown = down; }
|
||||||
|
void SetAltDown(bool down) { m_altDown = down; }
|
||||||
|
void SetMetaDown(bool down) { m_metaDown = down; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxCoord m_x;
|
||||||
|
wxCoord m_y;
|
||||||
|
|
||||||
|
bool m_leftDown;
|
||||||
|
bool m_middleDown;
|
||||||
|
bool m_rightDown;
|
||||||
|
|
||||||
|
bool m_controlDown;
|
||||||
|
bool m_shiftDown;
|
||||||
|
bool m_altDown;
|
||||||
|
bool m_metaDown;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Returns the current state of the mouse position, buttons and modifers
|
||||||
|
WXDLLEXPORT wxMouseState wxGetMouseState();
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Window ID management
|
// Window ID management
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -2672,6 +2672,31 @@ wxWindow *wxGetActiveWindow()
|
|||||||
return wxWindow::FindFocus();
|
return wxWindow::FindFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
GdkModifierType mask;
|
||||||
|
|
||||||
|
gdk_window_get_pointer(NULL, &x, &y, &mask);
|
||||||
|
|
||||||
|
ms.SetX(x);
|
||||||
|
ms.SetY(y);
|
||||||
|
ms.SetLeftDown(mask & GDK_BUTTON1_MASK);
|
||||||
|
ms.SetMiddleDown(mask & GDK_BUTTON2_MASK);
|
||||||
|
ms.SetRightDown(mask & GDK_BUTTON3_MASK);
|
||||||
|
|
||||||
|
ms.SetControlDown(mask & GDK_CONTROL_MASK);
|
||||||
|
ms.SetShiftDown(mask & GDK_SHIFT_MASK);
|
||||||
|
ms.SetAltDown(mask & GDK_MOD1_MASK);
|
||||||
|
ms.SetMetaDown(mask & GDK_MOD2_MASK);
|
||||||
|
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxWindowGTK
|
// wxWindowGTK
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -2672,6 +2672,31 @@ wxWindow *wxGetActiveWindow()
|
|||||||
return wxWindow::FindFocus();
|
return wxWindow::FindFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
GdkModifierType mask;
|
||||||
|
|
||||||
|
gdk_window_get_pointer(NULL, &x, &y, &mask);
|
||||||
|
|
||||||
|
ms.SetX(x);
|
||||||
|
ms.SetY(y);
|
||||||
|
ms.SetLeftDown(mask & GDK_BUTTON1_MASK);
|
||||||
|
ms.SetMiddleDown(mask & GDK_BUTTON2_MASK);
|
||||||
|
ms.SetRightDown(mask & GDK_BUTTON3_MASK);
|
||||||
|
|
||||||
|
ms.SetControlDown(mask & GDK_CONTROL_MASK);
|
||||||
|
ms.SetShiftDown(mask & GDK_SHIFT_MASK);
|
||||||
|
ms.SetAltDown(mask & GDK_MOD1_MASK);
|
||||||
|
ms.SetMetaDown(mask & GDK_MOD2_MASK);
|
||||||
|
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxWindowGTK
|
// wxWindowGTK
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -1499,6 +1499,29 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
|
||||||
|
wxPoint pt = wxGetMousePosition();
|
||||||
|
ms.SetX(pt.x);
|
||||||
|
ms.SetY(pt.y);
|
||||||
|
|
||||||
|
UInt32 buttons = GetCurrentButtonState();
|
||||||
|
ms.SetLeftDown( (buttons & 0x01) != 0 );
|
||||||
|
ms.SetMiddleDown( (buttons & 0x04) != 0 );
|
||||||
|
ms.SetRightDown( (buttons & 0x02) != 0 );
|
||||||
|
|
||||||
|
UInt32 modifiers = GetCurrentKeyModifiers();
|
||||||
|
ms.SetControlDown(modifiers & controlKey);
|
||||||
|
ms.SetShiftDown(modifiers & shiftKey);
|
||||||
|
ms.SetAltDown(modifiers & optionKey);
|
||||||
|
ms.SetMetaDown(modifiers & cmdKey);
|
||||||
|
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar )
|
bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar )
|
||||||
{
|
{
|
||||||
if ( !focus )
|
if ( !focus )
|
||||||
|
@@ -5390,6 +5390,28 @@ bool wxGetKeyState(wxKeyCode key)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
POINT pt;
|
||||||
|
GetCursorPos( &pt );
|
||||||
|
|
||||||
|
ms.SetX(pt.x);
|
||||||
|
ms.SetY(pt.y);
|
||||||
|
ms.SetLeftDown( (GetAsyncKeyState(VK_LBUTTON) & (1<<15)) != 0 );
|
||||||
|
ms.SetMiddleDown( (GetAsyncKeyState(VK_MBUTTON) & (1<<15)) != 0 );
|
||||||
|
ms.SetRightDown( (GetAsyncKeyState(VK_RBUTTON) & (1<<15)) != 0 );
|
||||||
|
|
||||||
|
ms.SetControlDown( (GetAsyncKeyState(VK_CONTROL) & (1<<15)) != 0 );
|
||||||
|
ms.SetShiftDown( (GetAsyncKeyState(VK_SHIFT) & (1<<15)) != 0 );
|
||||||
|
ms.SetAltDown( (GetAsyncKeyState(VK_MENU) & (1<<15)) != 0 );
|
||||||
|
// ms.SetMetaDown();
|
||||||
|
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxWindow *wxGetActiveWindow()
|
wxWindow *wxGetActiveWindow()
|
||||||
{
|
{
|
||||||
HWND hWnd = GetActiveWindow();
|
HWND hWnd = GetActiveWindow();
|
||||||
|
Reference in New Issue
Block a user