From 8866abbb1727c74a5c9caf949bb946db6e183d94 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 29 Oct 2007 22:31:18 +0000 Subject: [PATCH] add wxMouseEvent::GetClickCount() and implement it for wxMac git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/mouseevt.tex | 14 ++++++++++++++ include/wx/event.h | 8 +++++++- src/common/event.cpp | 20 +++++++++++++------- src/mac/carbon/toplevel.cpp | 1 + 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index ceac161daf..7fd09acf4e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -189,6 +189,7 @@ All (GUI): - Added support for drop down toolbar buttons (Tim Kosse). - Added support for labels for toolbar controls (Vince Harron). - Added wxMessageDialog::SetMessage() and SetExtendedMessage(). +- Added wxMouseEvent::GetClickCount() (Julian Scheid) - Added wxBG_STYLE_TRANSPARENT background style (Julian Scheid) - Added XRCSIZERITEM() macro for obtaining sizers from XRC (Brian Vanderburg II) - New and improved wxFileCtrl (Diaa Sami and Marcin Wojdyr) diff --git a/docs/latex/wx/mouseevt.tex b/docs/latex/wx/mouseevt.tex index f7f87bf4b9..8a6cfb7898 100644 --- a/docs/latex/wx/mouseevt.tex +++ b/docs/latex/wx/mouseevt.tex @@ -366,6 +366,20 @@ double click events, {\tt wxMOUSE\_BTN\_MIDDLE} and {\tt wxMOUSE\_BTN\_RIGHT} for the same events for the middle and the right buttons respectively. +\membersection{wxMouseEvent::GetClickCount}\label{wxmouseeventgetclickcount} + +\constfunc{int}{GetClickCount}{\void} + +Returns the number of mouse clicks for this event: $1$ for a simple click, $2$ +for a double-click, $3$ for a triple-click and so on. + +Currently this function is implemented only in wxMac and returns $-1$ for the +other platforms (you can still distinguish simple clicks from double-clicks as +they generate different kinds of events however). + +\newsince{2.9.0} + + \membersection{wxMouseEvent::GetPosition}\label{wxmouseeventgetposition} \constfunc{wxPoint}{GetPosition}{\void} diff --git a/include/wx/event.h b/include/wx/event.h index 4fc87804d0..d63a1140ee 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -694,7 +694,7 @@ class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent { public: wxMouseEvent(wxEventType mouseType = wxEVT_NULL); - wxMouseEvent(const wxMouseEvent& event) : wxEvent(event) + wxMouseEvent(const wxMouseEvent& event) : wxEvent(event) { Assign(event); } // Was it a button event? (*doesn't* mean: is any button *down*?) @@ -777,6 +777,10 @@ public: // True if the mouse is just leaving the window bool Leaving() const { return (m_eventType == wxEVT_LEAVE_WINDOW); } + // Returns the number of mouse clicks associated with this event. + int GetClickCount() const { return m_clickCount; } + + // Find the position of the event void GetPosition(wxCoord *xpos, wxCoord *ypos) const { @@ -850,6 +854,8 @@ public: bool m_altDown; bool m_metaDown; + int m_clickCount; + int m_wheelAxis; int m_wheelRotation; int m_wheelDelta; diff --git a/src/common/event.cpp b/src/common/event.cpp index c1a2440e9e..5654a132fb 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -518,17 +518,23 @@ wxScrollWinEvent::wxScrollWinEvent(wxEventType commandType, wxMouseEvent::wxMouseEvent(wxEventType commandType) { m_eventType = commandType; - m_metaDown = false; - m_altDown = false; - m_controlDown = false; - m_shiftDown = false; + + m_x = 0; + m_y = 0; + m_leftDown = false; - m_rightDown = false; m_middleDown = false; + m_rightDown = false; m_aux1Down = false; m_aux2Down = false; - m_x = 0; - m_y = 0; + + m_controlDown = false; + m_shiftDown = false; + m_altDown = false; + m_metaDown = false; + + m_clickCount = -1; + m_wheelRotation = 0; m_wheelDelta = 0; m_linesPerAction = 0; diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index dec6597956..48ffe45bb3 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -272,6 +272,7 @@ void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) wxevent.m_controlDown = modifiers & controlKey; wxevent.m_altDown = modifiers & optionKey; wxevent.m_metaDown = modifiers & cmdKey; + wxevent.m_clickCount = clickCount; wxevent.SetTimestamp( cEvent.GetTicks() ) ; // a control click is interpreted as a right click -- 2.45.2