Gtk2: fixed keeping of SelStart() and SelLength().issue #23219

git-svn-id: trunk@39652 -
This commit is contained in:
zeljko 2012-12-25 10:25:04 +00:00
parent 55daa17ac3
commit ca39d63bd3
2 changed files with 11 additions and 11 deletions

View File

@ -457,13 +457,14 @@ begin
begin
// if we change selstart in OnChange event new cursor pos need to
// be postponed in TGtk2WSCustomEdit.SetSelStart
NeedCursorCheck := True;
if g_object_get_data(PGObject(Widget),'lcl-gtkentry-pasted-data') <> nil then
begin
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',nil);
gtk_editable_set_position(PGtkEditable(Widget), GStart);
end else
begin
NeedCursorCheck := True;
//NeedCursorCheck := True;
if gtk_minor_version < 17 then
begin
g_object_set_data(PGObject(Widget),'lcl-gtkentry-pasted-data',Widget);

View File

@ -1215,7 +1215,7 @@ begin
Entry := PGtkEntry(PWidgetInfo(Data)^.CoreWidget);
gtk_entry_select_region(Entry,
PWidgetInfo(Data)^.CursorPos,
PWidgetInfo(Data)^.SelLength);
PWidgetInfo(Data)^.CursorPos + PWidgetInfo(Data)^.SelLength);
g_idle_remove_by_data(Data);
end;
@ -1302,10 +1302,10 @@ begin
NewPos := Min(NewStart, Entry^.text_max_length)
else
NewPos := Min(NewStart, Entry^.text_length);
WidgetInfo := GetWidgetInfo(Entry);
WidgetInfo^.CursorPos := NewPos;
if LockOnChange(PgtkObject(Entry),0) > 0 then
begin
WidgetInfo := GetWidgetInfo(Entry);
WidgetInfo^.CursorPos := NewPos;
// postpone
g_idle_add(@gtk2WSDelayedSelStart, WidgetInfo);
end else
@ -1324,15 +1324,14 @@ begin
Entry := {%H-}PGtkEntry(ACustomEdit.Handle);
SelStart := GetSelStart(ACustomEdit);
WidgetInfo := GetWidgetInfo(Entry);
if WidgetInfo^.CursorPos = 0 then
WidgetInfo^.CursorPos := SelStart;
WidgetInfo^.SelLength := NewLength;
if LockOnChange(PgtkObject(Entry),0) > 0 then
begin
// delay setting of selection length. issue #20890
WidgetInfo := GetWidgetInfo(Entry);
if WidgetInfo^.CursorPos = 0 then
WidgetInfo^.CursorPos := SelStart;
WidgetInfo^.SelLength := SelStart + NewLength;
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo);
end else
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo)
else
gtk_entry_select_region(Entry,
SelStart,
SelStart + NewLength);