mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
Gtk2: fixed clipboard selection transfer for GtkEntry/GtkTextView. issue #24308
git-svn-id: trunk@41040 -
This commit is contained in:
parent
4a43383cae
commit
e63627537c
@ -1089,7 +1089,8 @@ end;
|
|||||||
function GtkEntryDelayClearCursorPos(AGtkWidget: Pointer): GBoolean; cdecl;
|
function GtkEntryDelayClearCursorPos(AGtkWidget: Pointer): GBoolean; cdecl;
|
||||||
var
|
var
|
||||||
Info: PWidgetInfo;
|
Info: PWidgetInfo;
|
||||||
//AStart,AEnd: gint;
|
p: Pgchar;
|
||||||
|
AStart,AEnd: gint;
|
||||||
begin
|
begin
|
||||||
Result := AGtkWidget <> nil;
|
Result := AGtkWidget <> nil;
|
||||||
if AGtkWidget <> nil then
|
if AGtkWidget <> nil then
|
||||||
@ -1098,8 +1099,10 @@ begin
|
|||||||
Info := GetWidgetInfo(AGtkWidget);
|
Info := GetWidgetInfo(AGtkWidget);
|
||||||
if Info <> nil then
|
if Info <> nil then
|
||||||
begin
|
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);
|
||||||
|
if (AStart <> AEnd) then
|
||||||
|
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), p, -1);
|
||||||
gtk_editable_select_region(PGtkEditable(AGtkWidget), 0, 0);
|
gtk_editable_select_region(PGtkEditable(AGtkWidget), 0, 0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2034,6 +2037,8 @@ var
|
|||||||
ShiftState: TShiftState;
|
ShiftState: TShiftState;
|
||||||
MappedXY: TPoint;
|
MappedXY: TPoint;
|
||||||
EventXY: TPoint;
|
EventXY: TPoint;
|
||||||
|
AClip: gtk2.PGtkClipboard;
|
||||||
|
AClipText: String;
|
||||||
|
|
||||||
{off $DEFINE VerboseMouseBugfix}
|
{off $DEFINE VerboseMouseBugfix}
|
||||||
|
|
||||||
@ -2211,6 +2216,24 @@ begin
|
|||||||
MessI.Keys := MessI.Keys or ShiftStateToKeys(ShiftState);
|
MessI.Keys := MessI.Keys or ShiftStateToKeys(ShiftState);
|
||||||
|
|
||||||
MessI.Result:=0;
|
MessI.Result:=0;
|
||||||
|
|
||||||
|
{always send LM_SETFOCUS first}
|
||||||
|
if ((MessI.Msg = LM_LBUTTONDOWN) or (MessI.Msg = LM_RBUTTONDOWN) or
|
||||||
|
(MessI.Msg = LM_MBUTTONDOWN) or (MessI.Msg = LM_LBUTTONDBLCLK)) and
|
||||||
|
not AWinControl.Focused and AWinControl.CanFocus and
|
||||||
|
not (csDesigning in AWinControl.ComponentState) and (AWinControl is TCustomEdit) then
|
||||||
|
begin
|
||||||
|
AClipText := '';
|
||||||
|
AClip := gtk_clipboard_get(GDK_SELECTION_PRIMARY);
|
||||||
|
if gtk_clipboard_get_owner(AClip) = AClip then
|
||||||
|
AClip := nil;
|
||||||
|
if (AClip <> nil) and gtk_clipboard_wait_is_text_available(AClip) then
|
||||||
|
AClipText := gtk_clipboard_wait_for_text(AClip);
|
||||||
|
LCLIntf.SetFocus(AWinControl.Handle);
|
||||||
|
if Assigned(AClip) then
|
||||||
|
gtk_clipboard_set_text(AClip, PgChar(AClipText), length(AClipText));
|
||||||
|
end;
|
||||||
|
|
||||||
// send the message directly to the LCL
|
// send the message directly to the LCL
|
||||||
NotifyApplicationUserInput(AWinControl, MessI.Msg);
|
NotifyApplicationUserInput(AWinControl, MessI.Msg);
|
||||||
Result := DeliverMessage(AWinControl, MessI);
|
Result := DeliverMessage(AWinControl, MessI);
|
||||||
|
Loading…
Reference in New Issue
Block a user