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 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);

View File

@ -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);
if LockOnChange(PgtkObject(Entry),0) > 0 then
begin
WidgetInfo := GetWidgetInfo(Entry); WidgetInfo := GetWidgetInfo(Entry);
WidgetInfo^.CursorPos := NewPos; WidgetInfo^.CursorPos := NewPos;
if LockOnChange(PgtkObject(Entry),0) > 0 then
begin
// 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);
if LockOnChange(PgtkObject(Entry),0) > 0 then
begin
// delay setting of selection length. issue #20890
WidgetInfo := GetWidgetInfo(Entry); WidgetInfo := GetWidgetInfo(Entry);
if WidgetInfo^.CursorPos = 0 then if WidgetInfo^.CursorPos = 0 then
WidgetInfo^.CursorPos := SelStart; WidgetInfo^.CursorPos := SelStart;
WidgetInfo^.SelLength := SelStart + NewLength; WidgetInfo^.SelLength := NewLength;
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo); if LockOnChange(PgtkObject(Entry),0) > 0 then
end else // delay setting of selection length. issue #20890
g_idle_add(@gtk2WSDelayedSetSelLength, WidgetInfo)
else
gtk_entry_select_region(Entry, gtk_entry_select_region(Entry,
SelStart, SelStart,
SelStart + NewLength); SelStart + NewLength);