Ensure that Enter key presses are never stolen from wxButton in wxMSW.
This commit fixes the following bug: when an in-place editor control containing an embedded button was used in wxDataViewCtrl, pressing Enter on the button would close the editor, accepting changes, instead as (generic) wxDataViewCtrl intercepts WXK_RETURN in its EVT_CHAR_HOOK handler. To prevent this from happening, wxButton now handles EVT_CHAR_HOOK itself and never lets the parent window intercept it if it's for WXK_RETURN. To ensure that normal wxEVT_KEY_DOWN and wxEVT_CHAR are still generated in this case, wxButton handler calls the new wxKeyEvent::DoAllowNextEvent() method that was added to allow suppressing EVT_CHAR_HOOK only, without affecting the subsequent events. DoAllowNextEvent() is currently only used in wxMSW but support for it was also added to wxGTK and (both) wxOSX ports. See #9102. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1707,6 +1707,15 @@ public:
|
||||
// Get Y position
|
||||
wxCoord GetY() const { return m_y; }
|
||||
|
||||
// Can be called from wxEVT_CHAR_HOOK handler to allow generation of normal
|
||||
// key events even though the event had been handled (by default they would
|
||||
// not be generated in this case).
|
||||
void DoAllowNextEvent() { m_allowNext = true; }
|
||||
|
||||
// Return the value of the "allow next" flag, for internal use only.
|
||||
bool IsNextEventAllowed() const { return m_allowNext; }
|
||||
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxKeyEvent(*this); }
|
||||
virtual wxEventCategory GetEventCategory() const { return wxEVT_CATEGORY_USER_INPUT; }
|
||||
|
||||
@@ -1750,6 +1759,8 @@ private:
|
||||
{
|
||||
if ( m_eventType == wxEVT_CHAR_HOOK )
|
||||
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
||||
|
||||
m_allowNext = false;
|
||||
}
|
||||
|
||||
// Copy only the event data present in this class, this is used by
|
||||
@@ -1768,6 +1779,11 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
// If this flag is true, the normal key events should still be generated
|
||||
// even if wxEVT_CHAR_HOOK had been handled. By default it is false as
|
||||
// handling wxEVT_CHAR_HOOK suppresses all the subsequent events.
|
||||
bool m_allowNext;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxKeyEvent)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user