mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-02 01:44:44 +02:00
Gtk2: fixed keeping of SelStart() and SelLength().issue #23219
git-svn-id: trunk@39652 -
This commit is contained in:
parent
55daa17ac3
commit
ca39d63bd3
@ -457,13 +457,14 @@ begin
|
|||||||
begin
|
begin
|
||||||
// if we change selstart in OnChange event new cursor pos need to
|
// if we change selstart in OnChange event new cursor pos need to
|
||||||
// be postponed in TGtk2WSCustomEdit.SetSelStart
|
// be postponed in TGtk2WSCustomEdit.SetSelStart
|
||||||
|
NeedCursorCheck := True;
|
||||||
if g_object_get_data(PGObject(Widget),'lcl-gtkentry-pasted-data') <> nil then
|
if g_object_get_data(PGObject(Widget),'lcl-gtkentry-pasted-data') <> nil then
|
||||||
begin
|
begin
|
||||||
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',nil);
|
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',nil);
|
||||||
gtk_editable_set_position(PGtkEditable(Widget), GStart);
|
gtk_editable_set_position(PGtkEditable(Widget), GStart);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
NeedCursorCheck := True;
|
//NeedCursorCheck := True;
|
||||||
if gtk_minor_version < 17 then
|
if gtk_minor_version < 17 then
|
||||||
begin
|
begin
|
||||||
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',Widget);
|
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',Widget);
|
||||||
|
@ -1215,7 +1215,7 @@ begin
|
|||||||
Entry := PGtkEntry(PWidgetInfo(Data)^.CoreWidget);
|
Entry := PGtkEntry(PWidgetInfo(Data)^.CoreWidget);
|
||||||
gtk_entry_select_region(Entry,
|
gtk_entry_select_region(Entry,
|
||||||
PWidgetInfo(Data)^.CursorPos,
|
PWidgetInfo(Data)^.CursorPos,
|
||||||
PWidgetInfo(Data)^.SelLength);
|
PWidgetInfo(Data)^.CursorPos + PWidgetInfo(Data)^.SelLength);
|
||||||
g_idle_remove_by_data(Data);
|
g_idle_remove_by_data(Data);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1302,10 +1302,10 @@ begin
|
|||||||
NewPos := Min(NewStart, Entry^.text_max_length)
|
NewPos := Min(NewStart, Entry^.text_max_length)
|
||||||
else
|
else
|
||||||
NewPos := Min(NewStart, Entry^.text_length);
|
NewPos := Min(NewStart, Entry^.text_length);
|
||||||
|
WidgetInfo := GetWidgetInfo(Entry);
|
||||||
|
WidgetInfo^.CursorPos := NewPos;
|
||||||
if LockOnChange(PgtkObject(Entry),0) > 0 then
|
if LockOnChange(PgtkObject(Entry),0) > 0 then
|
||||||
begin
|
begin
|
||||||
WidgetInfo := GetWidgetInfo(Entry);
|
|
||||||
WidgetInfo^.CursorPos := NewPos;
|
|
||||||
// postpone
|
// postpone
|
||||||
g_idle_add(@gtk2WSDelayedSelStart, WidgetInfo);
|
g_idle_add(@gtk2WSDelayedSelStart, WidgetInfo);
|
||||||
end else
|
end else
|
||||||
@ -1324,15 +1324,14 @@ begin
|
|||||||
Entry := {%H-}PGtkEntry(ACustomEdit.Handle);
|
Entry := {%H-}PGtkEntry(ACustomEdit.Handle);
|
||||||
SelStart := GetSelStart(ACustomEdit);
|
SelStart := GetSelStart(ACustomEdit);
|
||||||
|
|
||||||
|
WidgetInfo := GetWidgetInfo(Entry);
|
||||||
|
if WidgetInfo^.CursorPos = 0 then
|
||||||
|
WidgetInfo^.CursorPos := SelStart;
|
||||||
|
WidgetInfo^.SelLength := NewLength;
|
||||||
if LockOnChange(PgtkObject(Entry),0) > 0 then
|
if LockOnChange(PgtkObject(Entry),0) > 0 then
|
||||||
begin
|
|
||||||
// delay setting of selection length. issue #20890
|
// delay setting of selection length. issue #20890
|
||||||
WidgetInfo := GetWidgetInfo(Entry);
|
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo)
|
||||||
if WidgetInfo^.CursorPos = 0 then
|
else
|
||||||
WidgetInfo^.CursorPos := SelStart;
|
|
||||||
WidgetInfo^.SelLength := SelStart + NewLength;
|
|
||||||
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo);
|
|
||||||
end else
|
|
||||||
gtk_entry_select_region(Entry,
|
gtk_entry_select_region(Entry,
|
||||||
SelStart,
|
SelStart,
|
||||||
SelStart + NewLength);
|
SelStart + NewLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user