Add IM and full wxEVT_CHAR support to wxTextCtrl and wxComboBox in wxGTK.

Generate wxEVT_CHAR events for non-ASCII characters entered in these controls
by intercepting their insert-text signal.

Also try to use GtkEntry/GtkTextView internal IM objects but unsuccessfully so
far.

Closes #3158.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-03-21 22:37:09 +00:00
parent c77ef57e6e
commit b2c357747d
7 changed files with 154 additions and 50 deletions

View File

@@ -1069,24 +1069,32 @@ static void
gtk_wxwindow_commit_cb (GtkIMContext * WXUNUSED(context),
const gchar *str,
wxWindow *window)
{
// Ignore the return value here, it doesn't matter for the "commit" signal.
window->GTKDoInsertTextFromIM(str);
}
}
bool wxWindowGTK::GTKDoInsertTextFromIM(const char* str)
{
wxKeyEvent event( wxEVT_CHAR );
// take modifiers, cursor position, timestamp etc. from the last
// key_press_event that was fed into Input Method:
if (window->m_imKeyEvent)
if ( m_imKeyEvent )
{
wxFillOtherKeyEventFields(event, window, window->m_imKeyEvent);
wxFillOtherKeyEventFields(event, this, m_imKeyEvent);
}
else
{
event.SetEventObject( window );
event.SetEventObject(this);
}
const wxString data(wxGTK_CONV_BACK_SYS(str));
if( data.empty() )
return;
return false;
bool processed = false;
for( wxString::const_iterator pstr = data.begin(); pstr != data.end(); ++pstr )
{
#if wxUSE_UNICODE
@@ -1100,9 +1108,22 @@ gtk_wxwindow_commit_cb (GtkIMContext * WXUNUSED(context),
AdjustCharEventKeyCodes(event);
window->HandleWindowEvent(event);
if ( HandleWindowEvent(event) )
processed = true;
}
return processed;
}
bool wxWindowGTK::GTKOnInsertText(const char* text)
{
if ( !m_imKeyEvent )
{
// We're not inside IM key handling at all.
return false;
}
return GTKDoInsertTextFromIM(text);
}