Copy/Paste content of TEdit (gtk2) in linux X11 by mouse middle button does not work
Original Reporter info from Mantis: Petr-K
-
Reporter name:
Original Reporter info from Mantis: Petr-K
- Reporter name:
Description:
When I select text in TEdit and switch to another aplication (to paste a content),
selection in TEdit disappear.
Gtk2 primary selection clipboard was cleared after gtk_editable lose focus.
Code responsible for that is in GtkEntryDelayClearCursorPos (workaround issues #18164 (closed),#21897 (closed),#23182 (closed))
Here is a little patch to solve this. Selected text is stored to PRIMARY clipboard before selection is canceled.
--- gtk2callback.inc (revision 39991)
+++ gtk2callback.inc (working copy)
@@ -1089,7 +1089,8 @@
function GtkEntryDelayClearCursorPos(AGtkWidget: Pointer): GBoolean; cdecl;
var
Info: PWidgetInfo;
- //AStart,AEnd: gint;
+ AStart,AEnd: gint;
+ p: Pgchar;
begin
Result := AGtkWidget <> nil;
if AGtkWidget <> nil then
@@ -1098,8 +1099,10 @@
Info := GetWidgetInfo(AGtkWidget);
if Info <> nil then
begin
- //gtk_editable_get_selection_bounds(PGtkEditable(AGtkWidget),@AStart, @AEnd);
+ gtk_editable_get_selection_bounds(PGtkEditable(AGtkWidget),@AStart, @AEnd);
//Info^.CursorPos := AEnd;
+ p := gtk_editable_get_chars(PGtkEditable(AGtkWidget), AStart, AEnd);
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), p, -1);
gtk_editable_select_region(PGtkEditable(AGtkWidget), 0, 0);
end;
end;
Steps to reproduce:
Select text in TEdit and switch to another application and paste by middle mouse button. None is pasted, because buffer is empty.
Mantis conversion info:
- Mantis ID: 24308
- OS: Linux
- Build: Revision #39991 (closed)
- Version: 1.1 (SVN)
- Fixed in revision: 41040 (#e6362753)