mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 10:19:16 +02:00
carbon: fix for too small CarbonEdit endless loops.
git-svn-id: trunk@26357 -
This commit is contained in:
parent
5f5c540897
commit
bcb0f4c05e
@ -153,7 +153,17 @@ type
|
|||||||
|
|
||||||
TCarbonEdit = class(TCarbonCustomEdit)
|
TCarbonEdit = class(TCarbonCustomEdit)
|
||||||
private
|
private
|
||||||
FIsPassword: Boolean;
|
FIsPassword : Boolean;
|
||||||
|
|
||||||
|
// Native Carbon edit's bounds are changing "internal edit" control (not the frame) //
|
||||||
|
// for this reason EditExtra* constants have been introduced. //
|
||||||
|
// So the bounds of the frame a changed (for LCL compatibility); //
|
||||||
|
// Howevr, GetFrameBounds cannot return correct value, if Bounds of the edit //
|
||||||
|
// is smaller than EditExtraLeft + EditExtraRight, or EditExtraTop+EditExtraBottom //
|
||||||
|
// Incorrect returned bounds is causes endless loop in LCL processing. //
|
||||||
|
// For this reason "TooSmall" flag is introduced to return smaller size of the control //
|
||||||
|
FTooSmall : Boolean;
|
||||||
|
FSmallBounds : TRect;
|
||||||
protected
|
protected
|
||||||
procedure CreateWidget(const AParams: TCreateParams); override;
|
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||||
function GetFrameBounds(var r: TRect): Boolean; override;
|
function GetFrameBounds(var r: TRect): Boolean; override;
|
||||||
@ -1431,16 +1441,38 @@ begin
|
|||||||
dec(r.Bottom, EditExtraBottom);
|
dec(r.Bottom, EditExtraBottom);
|
||||||
inc(r.Left, EditExtraLeft);
|
inc(r.Left, EditExtraLeft);
|
||||||
dec(r.Right, EditExtraRight);
|
dec(r.Right, EditExtraRight);
|
||||||
|
|
||||||
|
FTooSmall:=False;
|
||||||
|
if r.Right<r.Left then
|
||||||
|
begin
|
||||||
|
FTooSmall:=True;
|
||||||
|
r.Right:=r.Left;
|
||||||
|
end;
|
||||||
|
if r.Bottom<r.Top then
|
||||||
|
begin
|
||||||
|
FTooSmall:=True;
|
||||||
|
r.Bottom:=r.Top;
|
||||||
|
end;
|
||||||
|
if FTooSmall then FSmallBounds:=ARect;
|
||||||
|
|
||||||
Result := inherited SetBounds(r);
|
Result := inherited SetBounds(r);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonEdit.GetFrameBounds(var r: TRect): Boolean;
|
function TCarbonEdit.GetFrameBounds(var r: TRect): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := inherited GetFrameBounds(r);
|
if FTooSmall then
|
||||||
dec(r.Top, EditExtraTop);
|
begin
|
||||||
inc(r.Bottom, EditExtraBottom);
|
r:=FSmallBounds;
|
||||||
dec(r.Left, EditExtraLeft);
|
Result:=True;
|
||||||
inc(r.Right, EditExtraRight);
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Result := inherited GetFrameBounds(r);
|
||||||
|
dec(r.Top, EditExtraTop);
|
||||||
|
inc(r.Bottom, EditExtraBottom);
|
||||||
|
dec(r.Left, EditExtraLeft);
|
||||||
|
inc(r.Right, EditExtraRight);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user