Generate clipboard events for wxComboBox in wxGTK too.
These events were only generated for wxTextCtrl but should be sent for non-readonly wxComboBox too, so refactor the code to allow its reuse from wxComboBox. Also add EVT_TEXT_PASTE handlers for both controls to the widgets sample for testing. Closes #14520. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,11 +39,9 @@
|
||||
// signal handlers implementation
|
||||
// ============================================================================
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
// "insert_text" handler for GtkEntry
|
||||
static void
|
||||
extern "C"
|
||||
void
|
||||
wx_gtk_insert_text_callback(GtkEditable *editable,
|
||||
const gchar * WXUNUSED(new_text),
|
||||
gint WXUNUSED(new_text_length),
|
||||
@@ -74,6 +72,51 @@ wx_gtk_insert_text_callback(GtkEditable *editable,
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// clipboard events: "copy-clipboard", "cut-clipboard", "paste-clipboard"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// common part of the event handlers below
|
||||
static void
|
||||
DoHandleClipboardCallback( GtkWidget *widget,
|
||||
wxWindow *win,
|
||||
wxEventType eventType,
|
||||
const gchar* signal_name)
|
||||
{
|
||||
wxClipboardTextEvent event( eventType, win->GetId() );
|
||||
event.SetEventObject( win );
|
||||
if ( win->HandleWindowEvent( event ) )
|
||||
{
|
||||
// don't let the default processing to take place if we did something
|
||||
// ourselves in the event handler
|
||||
g_signal_stop_emission_by_name (widget, signal_name);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
static void
|
||||
wx_gtk_copy_clipboard_callback( GtkWidget *widget, wxWindow *win )
|
||||
{
|
||||
DoHandleClipboardCallback(
|
||||
widget, win, wxEVT_COMMAND_TEXT_COPY, "copy-clipboard" );
|
||||
}
|
||||
|
||||
static void
|
||||
wx_gtk_cut_clipboard_callback( GtkWidget *widget, wxWindow *win )
|
||||
{
|
||||
DoHandleClipboardCallback(
|
||||
widget, win, wxEVT_COMMAND_TEXT_CUT, "cut-clipboard" );
|
||||
}
|
||||
|
||||
static void
|
||||
wx_gtk_paste_clipboard_callback( GtkWidget *widget, wxWindow *win )
|
||||
{
|
||||
DoHandleClipboardCallback(
|
||||
widget, win, wxEVT_COMMAND_TEXT_PASTE, "paste-clipboard" );
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
// ============================================================================
|
||||
@@ -147,6 +190,19 @@ void wxTextEntry::Remove(long from, long to)
|
||||
// clipboard operations
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextEntry::GTKConnectClipboardSignals(GtkWidget* entry)
|
||||
{
|
||||
g_signal_connect(entry, "copy-clipboard",
|
||||
G_CALLBACK (wx_gtk_copy_clipboard_callback),
|
||||
GetEditableWindow());
|
||||
g_signal_connect(entry, "cut-clipboard",
|
||||
G_CALLBACK (wx_gtk_cut_clipboard_callback),
|
||||
GetEditableWindow());
|
||||
g_signal_connect(entry, "paste-clipboard",
|
||||
G_CALLBACK (wx_gtk_paste_clipboard_callback),
|
||||
GetEditableWindow());
|
||||
}
|
||||
|
||||
void wxTextEntry::Copy()
|
||||
{
|
||||
gtk_editable_copy_clipboard(GetEditable());
|
||||
|
Reference in New Issue
Block a user