mouse event flags have MSW-compatible values for click/release events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-12 14:57:21 +00:00
parent c92b0f9abd
commit 2daa0ce9a4
2 changed files with 148 additions and 62 deletions

View File

@@ -895,6 +895,38 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
return FALSE;
}
// ----------------------------------------------------------------------------
// mouse event processing helper
// ----------------------------------------------------------------------------
static void AdjustEventButtonState(wxMouseEvent& event)
{
// GDK reports the old state of the button for a button press event, but
// for compatibility with MSW and common sense we want m_leftDown be TRUE
// for a LEFT_DOWN event, not FALSE, so we will invert
// left/right/middleDown for the corresponding click events
switch ( event.GetEventType() )
{
case wxEVT_LEFT_DOWN:
case wxEVT_LEFT_DCLICK:
case wxEVT_LEFT_UP:
event.m_leftDown = !event.m_leftDown;
break;
case wxEVT_MIDDLE_DOWN:
case wxEVT_MIDDLE_DCLICK:
case wxEVT_MIDDLE_UP:
event.m_middleDown = !event.m_middleDown;
break;
case wxEVT_RIGHT_DOWN:
case wxEVT_RIGHT_DCLICK:
case wxEVT_RIGHT_UP:
event.m_rightDown = !event.m_rightDown;
break;
}
}
//-----------------------------------------------------------------------------
// "button_press_event"
//-----------------------------------------------------------------------------
@@ -934,7 +966,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
}
}
wxEventType event_type = wxEVT_LEFT_DOWN;
wxEventType event_type = wxEVT_NULL;
if (gdk_event->button == 1)
{
@@ -964,6 +996,12 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
}
}
if ( event_type == wxEVT_NULL )
{
// unknown mouse button or click type
return FALSE;
}
wxMouseEvent event( event_type );
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
@@ -977,6 +1015,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
event.m_x = (wxCoord)gdk_event->x;
event.m_y = (wxCoord)gdk_event->y;
AdjustEventButtonState(event);
// Some control don't have their own X window and thus cannot get
// any events.
@@ -1092,6 +1132,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
case 1: event_type = wxEVT_LEFT_UP; break;
case 2: event_type = wxEVT_MIDDLE_UP; break;
case 3: event_type = wxEVT_RIGHT_UP; break;
default: return FALSE;
}
wxMouseEvent event( event_type );
@@ -1106,6 +1147,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
event.m_x = (wxCoord)gdk_event->x;
event.m_y = (wxCoord)gdk_event->y;
AdjustEventButtonState(event);
// Some control don't have their own X window and thus cannot get
// any events.

View File

@@ -895,6 +895,38 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
return FALSE;
}
// ----------------------------------------------------------------------------
// mouse event processing helper
// ----------------------------------------------------------------------------
static void AdjustEventButtonState(wxMouseEvent& event)
{
// GDK reports the old state of the button for a button press event, but
// for compatibility with MSW and common sense we want m_leftDown be TRUE
// for a LEFT_DOWN event, not FALSE, so we will invert
// left/right/middleDown for the corresponding click events
switch ( event.GetEventType() )
{
case wxEVT_LEFT_DOWN:
case wxEVT_LEFT_DCLICK:
case wxEVT_LEFT_UP:
event.m_leftDown = !event.m_leftDown;
break;
case wxEVT_MIDDLE_DOWN:
case wxEVT_MIDDLE_DCLICK:
case wxEVT_MIDDLE_UP:
event.m_middleDown = !event.m_middleDown;
break;
case wxEVT_RIGHT_DOWN:
case wxEVT_RIGHT_DCLICK:
case wxEVT_RIGHT_UP:
event.m_rightDown = !event.m_rightDown;
break;
}
}
//-----------------------------------------------------------------------------
// "button_press_event"
//-----------------------------------------------------------------------------
@@ -934,7 +966,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
}
}
wxEventType event_type = wxEVT_LEFT_DOWN;
wxEventType event_type = wxEVT_NULL;
if (gdk_event->button == 1)
{
@@ -964,6 +996,12 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
}
}
if ( event_type == wxEVT_NULL )
{
// unknown mouse button or click type
return FALSE;
}
wxMouseEvent event( event_type );
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
@@ -977,6 +1015,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
event.m_x = (wxCoord)gdk_event->x;
event.m_y = (wxCoord)gdk_event->y;
AdjustEventButtonState(event);
// Some control don't have their own X window and thus cannot get
// any events.
@@ -1092,6 +1132,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
case 1: event_type = wxEVT_LEFT_UP; break;
case 2: event_type = wxEVT_MIDDLE_UP; break;
case 3: event_type = wxEVT_RIGHT_UP; break;
default: return FALSE;
}
wxMouseEvent event( event_type );
@@ -1106,6 +1147,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
event.m_x = (wxCoord)gdk_event->x;
event.m_y = (wxCoord)gdk_event->y;
AdjustEventButtonState(event);
// Some control don't have their own X window and thus cannot get
// any events.