Generate the same flags for modifier key events in wxGTK as in wxMSW.
Resolve the discrepancy between modifier flags of the key events corresponding to the modifier key itself between wxMSW and wxGTK by changing the latter to follow wxMSW behaviour. Clearly document the now officially correct behaviour of the modifiers for the key events corresponding to the modifiers keys themselves in the manual. This fix also makes it unnecessary to work around this bug in the keyboard unit test so remove it from there. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -680,12 +680,57 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event,
|
||||
|
||||
event.SetTimestamp( gdk_event->time );
|
||||
event.SetId(win->GetId());
|
||||
|
||||
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0;
|
||||
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0;
|
||||
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
|
||||
event.m_metaDown = (gdk_event->state & GDK_META_MASK) != 0;
|
||||
|
||||
// Normally we take the state of modifiers directly from the low level GDK
|
||||
// event but unfortunately GDK uses a different convention from MSW for the
|
||||
// key events corresponding to the modifier keys themselves: in it, when
|
||||
// e.g. Shift key is pressed, GDK_SHIFT_MASK is not set while it is set
|
||||
// when Shift is released. Under MSW the situation is exactly reversed and
|
||||
// the modifier corresponding to the key is set when it is pressed and
|
||||
// unset when it is released. To ensure consistent behaviour between
|
||||
// platforms (and because it seems to make slightly more sense, although
|
||||
// arguably both behaviours are reasonable) we follow MSW here.
|
||||
//
|
||||
// Final notice: we set the flags to the desired value instead of just
|
||||
// inverting them because they are not set correctly (i.e. in the same way
|
||||
// as for the real events generated by the user) for wxUIActionSimulator-
|
||||
// produced events and it seems better to keep that class code the same
|
||||
// among all platforms and fix the discrepancy here instead of adding
|
||||
// wxGTK-specific code to wxUIActionSimulator.
|
||||
const bool isPress = gdk_event->type == GDK_KEY_PRESS;
|
||||
switch ( gdk_event->keyval )
|
||||
{
|
||||
case GDK_Shift_L:
|
||||
case GDK_Shift_R:
|
||||
event.m_shiftDown = isPress;
|
||||
break;
|
||||
|
||||
case GDK_Control_L:
|
||||
case GDK_Control_R:
|
||||
event.m_controlDown = isPress;
|
||||
break;
|
||||
|
||||
case GDK_Alt_L:
|
||||
case GDK_Alt_R:
|
||||
event.m_altDown = isPress;
|
||||
break;
|
||||
|
||||
case GDK_Meta_L:
|
||||
case GDK_Meta_R:
|
||||
case GDK_Super_L:
|
||||
case GDK_Super_R:
|
||||
event.m_metaDown = isPress;
|
||||
break;
|
||||
}
|
||||
|
||||
event.m_rawCode = (wxUint32) gdk_event->keyval;
|
||||
event.m_rawFlags = 0;
|
||||
|
||||
wxGetMousePosition( &x, &y );
|
||||
win->ScreenToClient( &x, &y );
|
||||
event.m_x = x;
|
||||
|
Reference in New Issue
Block a user