mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 19:35:58 +02:00
TCustomEdit now tries to keep the selection position after replacing the selection from Colin
git-svn-id: trunk@9250 -
This commit is contained in:
parent
0c71fadd58
commit
5c9068adf1
@ -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;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user