TCustomEdit now tries to keep the selection position after replacing the selection from Colin

git-svn-id: trunk@9250 -
This commit is contained in:
mattias 2006-05-08 08:52:14 +00:00
parent 0c71fadd58
commit 5c9068adf1
2 changed files with 5 additions and 1 deletions

View File

@ -91,11 +91,14 @@ end;
procedure TCustomEdit.SetSelText(const Val : string);
var
OldText, NewText: string;
OldPos: Integer;
begin
OldPos := SelStart;
OldText:=Text;
NewText:=LeftStr(OldText,SelStart)+Val
+RightStr(OldText,length(OldText)-SelStart-SelLength);
Text:=NewText;
SelStart := OldPos + Length(Val);
end;
{------------------------------------------------------------------------------

View File

@ -826,11 +826,12 @@ Widget: PGtkWidget;
begin
Widget:=GetWidgetInfo(Pointer(ACustomEdit.Handle), true)^.CoreWidget;
if WidgetGetSelStart(Widget)=NewStart then exit;
// sometimes the gtk freezes the memo, canges something and emits the change
// sometimes the gtk freezes the memo, changes something and emits the change
// event. Then the LCL gets notified and wants to react: force thaw (unfreeze)
if GTK_IS_TEXT(Widget) then
gtk_text_thaw(PGtkText(Widget));
gtk_editable_set_position(PGtkOldEditable(Widget), NewStart);
WidgetSetSelLength(Widget,0); // Setting the selection start should cancel any selection
end;
procedure TGtkWSCustomEdit.SetSelLength(const ACustomEdit: TCustomEdit;