From e0e6f3dc808e4c2aa4942375758b4eea60d0c665 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Jan 2013 12:45:52 +0000 Subject: [PATCH] Fix wxKeyEvent::GetPosition() after the changes of r72207. Now that the position of wxKeyEvent is initialized on demand, don't use m_x and m_y fields directly but always use GetX() and GetY(). Also improve GetPosition() documentation slightly and mention only the new version, taking wxCoord, in it as the old one, taking long, is provided for compatiblity only. Closes #14987. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73411 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/event.h | 17 ++++++++++++----- interface/wx/event.h | 10 +++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/wx/event.h b/include/wx/event.h index 6e4805549c..df5cb310a5 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1862,18 +1862,23 @@ public: // Find the position of the event void GetPosition(wxCoord *xpos, wxCoord *ypos) const { - if (xpos) *xpos = m_x; - if (ypos) *ypos = m_y; + if (xpos) + *xpos = GetX(); + if (ypos) + *ypos = GetY(); } + // This version if provided only for backwards compatiblity, don't use. void GetPosition(long *xpos, long *ypos) const { - if (xpos) *xpos = (long)m_x; - if (ypos) *ypos = (long)m_y; + if (xpos) + *xpos = GetX(); + if (ypos) + *ypos = GetY(); } wxPoint GetPosition() const - { return wxPoint(m_x, m_y); } + { return wxPoint(GetX(), GetY()); } // Get X position wxCoord GetX() const; @@ -1911,6 +1916,8 @@ public: } public: + // Do not use these fields directly, they are initialized on demand, so + // call GetX() and GetY() or GetPosition() instead. wxCoord m_x, m_y; long m_keyCode; diff --git a/interface/wx/event.h b/interface/wx/event.h index a6424f5123..f5d1b1e687 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -1543,11 +1543,15 @@ public: /** Obtains the position (in client coordinates) at which the key was pressed. - Notice that this position is simply the current mouse pointer position - and has no special relationship to the key event itself. + Notice that under most platforms this position is simply the current + mouse pointer position and has no special relationship to the key event + itself. + + @a x and @a y may be @NULL if the corresponding coordinate is not + needed. */ wxPoint GetPosition() const; - void GetPosition(long* x, long* y) const; + void GetPosition(wxCoord* x, wxCoord* y) const; //@} /**