mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 14:18:17 +02:00
LazControl: LazIntegerEdit, improve selection after changing sign/base. Issue #41082
This commit is contained in:
parent
ac53164253
commit
c924cafb5f
@ -346,18 +346,24 @@ procedure TLazIntegerEditGen.UpdateText(ANewText: string; AnAdjustPos: Integer;
|
|||||||
AnAdjustOffs: Integer; AWasEmpty: boolean);
|
AnAdjustOffs: Integer; AWasEmpty: boolean);
|
||||||
var
|
var
|
||||||
sb, se, m: Integer;
|
sb, se, m: Integer;
|
||||||
|
ToEnd: Boolean;
|
||||||
begin
|
begin
|
||||||
sb := SelStart;
|
sb := SelStart;
|
||||||
se := sb+SelLength;
|
se := sb+SelLength;
|
||||||
|
ToEnd := se = Length(Text);
|
||||||
Text := ANewText;
|
Text := ANewText;
|
||||||
|
|
||||||
if AnAdjustOffs <> 0 then begin
|
if AnAdjustOffs <> 0 then begin
|
||||||
m := AnAdjustPos;
|
m := AnAdjustPos;
|
||||||
if AnAdjustOffs < 0 then m := m + AnAdjustOffs;
|
if AnAdjustOffs < 0 then m := m + AnAdjustOffs;
|
||||||
if sb >= AnAdjustPos then sb := Max(m, sb + AnAdjustOffs);
|
if (sb >= AnAdjustPos) and
|
||||||
if se >= AnAdjustPos then se := Max(m, se + AnAdjustOffs);
|
not((sb=0) and ToEnd)
|
||||||
|
then
|
||||||
|
sb := Max(m, sb + AnAdjustOffs);
|
||||||
|
if se >= AnAdjustPos then
|
||||||
|
se := Max(m, se + AnAdjustOffs);
|
||||||
end;
|
end;
|
||||||
if AWasEmpty then
|
if AWasEmpty or ToEnd then
|
||||||
se := Length(ANewText);
|
se := Length(ANewText);
|
||||||
|
|
||||||
SelStart := sb;
|
SelStart := sb;
|
||||||
@ -597,13 +603,17 @@ begin
|
|||||||
else
|
else
|
||||||
if FAllowMinus and (key = '-') then begin
|
if FAllowMinus and (key = '-') then begin
|
||||||
DecodeText(p, v, False);
|
DecodeText(p, v, False);
|
||||||
UpdateText(EncodeText(p, -v, FLastDecodeWasEmpty));
|
if v > 0 then
|
||||||
|
UpdateText(EncodeText(p, -v, FLastDecodeWasEmpty), 0, 1)
|
||||||
|
else
|
||||||
|
if v < 0 then
|
||||||
|
UpdateText(EncodeText(p, -v, FLastDecodeWasEmpty), 1, -1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if FAllowPlus and (key = '+') then begin
|
if FAllowPlus and (key = '+') then begin
|
||||||
DecodeText(p, v, False);
|
DecodeText(p, v, False);
|
||||||
if v < 0 then
|
if v < 0 then
|
||||||
UpdateText(EncodeText(p, -v, FLastDecodeWasEmpty));
|
UpdateText(EncodeText(p, -v, FLastDecodeWasEmpty), 1, -1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Key := #0;
|
Key := #0;
|
||||||
|
Loading…
Reference in New Issue
Block a user