Corrected double clicks (always on the same window).

Corrected mouse up events (same window as mouse down).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-05-05 11:36:33 +00:00
parent a9d171bd00
commit 32b5be3d67
6 changed files with 374 additions and 320 deletions

View File

@@ -183,7 +183,9 @@ void wxTextCtrl::SetValue(const wxString& st)
else
value = st ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
MacRedrawControl() ;
Update();
}
// Clipboard operations

View File

@@ -54,6 +54,14 @@
// list of all frames and modeless dialogs
wxWindowList wxModelessWindows;
// double click testing
static Point gs_lastWhere;
static long gs_lastWhen = 0;
// cursor stuff
extern int wxBusyCursorCount;
// ============================================================================
// wxTopLevelWindowMac implementation
// ============================================================================
@@ -347,10 +355,6 @@ void wxTopLevelWindowMac::Lower()
::SendBehind( (WindowRef)m_macWindow , NULL ) ;
}
Point lastWhere ;
long lastWhen = 0 ;
extern int wxBusyCursorCount ;
void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
{
EventRecord *ev = (EventRecord*) evr ;
@@ -397,22 +401,25 @@ void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
if ( ev->what == mouseDown )
{
if ( ev->when - lastWhen <= GetDblTime() )
if ( ev->when - gs_lastWhen <= GetDblTime() )
{
if ( abs( localwhere.h - lastWhere.h ) < 3 || abs( localwhere.v - lastWhere.v ) < 3 )
if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
{
// This is not right if the second mouse down
// event occured in a differen window. We
// correct this in MacDispatchMouseEvent.
if ( controlDown )
event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
else
event.SetEventType(wxEVT_LEFT_DCLICK ) ;
}
lastWhen = 0 ;
gs_lastWhen = 0 ;
}
else
{
lastWhen = ev->when ;
gs_lastWhen = ev->when ;
}
lastWhere = localwhere ;
gs_lastWhere = localwhere ;
}
event.m_x = localwhere.h;

View File

@@ -1386,6 +1386,7 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa
}
extern int wxBusyCursorCount ;
static wxWindow *gs_lastWhich = NULL;
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
{
@@ -1438,6 +1439,23 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
wxToolTip::RelayEvent( this , event);
#endif // wxUSE_TOOLTIPS
if (gs_lastWhich != this)
{
gs_lastWhich = this;
// Double clicks must always occur on the same window
if (event.GetEventType() == wxEVT_LEFT_DCLICK)
event.SetEventType( wxEVT_LEFT_DOWN );
if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
event.SetEventType( wxEVT_RIGHT_DOWN );
// Same for mouse up events
if (event.GetEventType() == wxEVT_LEFT_UP)
return TRUE;
if (event.GetEventType() == wxEVT_RIGHT_UP)
return TRUE;
}
GetEventHandler()->ProcessEvent( event ) ;
return TRUE;

View File

@@ -183,7 +183,9 @@ void wxTextCtrl::SetValue(const wxString& st)
else
value = st ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
MacRedrawControl() ;
Update();
}
// Clipboard operations

View File

@@ -54,6 +54,14 @@
// list of all frames and modeless dialogs
wxWindowList wxModelessWindows;
// double click testing
static Point gs_lastWhere;
static long gs_lastWhen = 0;
// cursor stuff
extern int wxBusyCursorCount;
// ============================================================================
// wxTopLevelWindowMac implementation
// ============================================================================
@@ -347,10 +355,6 @@ void wxTopLevelWindowMac::Lower()
::SendBehind( (WindowRef)m_macWindow , NULL ) ;
}
Point lastWhere ;
long lastWhen = 0 ;
extern int wxBusyCursorCount ;
void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
{
EventRecord *ev = (EventRecord*) evr ;
@@ -397,22 +401,25 @@ void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
if ( ev->what == mouseDown )
{
if ( ev->when - lastWhen <= GetDblTime() )
if ( ev->when - gs_lastWhen <= GetDblTime() )
{
if ( abs( localwhere.h - lastWhere.h ) < 3 || abs( localwhere.v - lastWhere.v ) < 3 )
if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
{
// This is not right if the second mouse down
// event occured in a differen window. We
// correct this in MacDispatchMouseEvent.
if ( controlDown )
event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
else
event.SetEventType(wxEVT_LEFT_DCLICK ) ;
}
lastWhen = 0 ;
gs_lastWhen = 0 ;
}
else
{
lastWhen = ev->when ;
gs_lastWhen = ev->when ;
}
lastWhere = localwhere ;
gs_lastWhere = localwhere ;
}
event.m_x = localwhere.h;

View File

@@ -1386,6 +1386,7 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa
}
extern int wxBusyCursorCount ;
static wxWindow *gs_lastWhich = NULL;
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
{
@@ -1438,6 +1439,23 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
wxToolTip::RelayEvent( this , event);
#endif // wxUSE_TOOLTIPS
if (gs_lastWhich != this)
{
gs_lastWhich = this;
// Double clicks must always occur on the same window
if (event.GetEventType() == wxEVT_LEFT_DCLICK)
event.SetEventType( wxEVT_LEFT_DOWN );
if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
event.SetEventType( wxEVT_RIGHT_DOWN );
// Same for mouse up events
if (event.GetEventType() == wxEVT_LEFT_UP)
return TRUE;
if (event.GetEventType() == wxEVT_RIGHT_UP)
return TRUE;
}
GetEventHandler()->ProcessEvent( event ) ;
return TRUE;