mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 10:19:23 +02:00
lcl/win32: move the TEdit.MaxLength check from lcl to win32 intf. Gtk2 and Qt has built in check and truncates text automatically
git-svn-id: trunk@23243 -
This commit is contained in:
parent
abdf00ce23
commit
ab2a0ee728
@ -391,19 +391,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Method: TCustomEdit.RealSetText
|
|
||||||
Params: Override of text setup to watch for max length
|
|
||||||
Returns: Nothing
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
procedure TCustomEdit.RealSetText(const Value: TCaption);
|
|
||||||
begin
|
|
||||||
if (MaxLength > 0) and (Length(Value) > MaxLength) then
|
|
||||||
inherited RealSetText(UTF8Copy(Value, 1, MaxLength))
|
|
||||||
else
|
|
||||||
inherited RealSetText(Value);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
|
function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
@ -174,6 +174,7 @@ type
|
|||||||
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
|
||||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||||
|
|
||||||
class procedure Undo(const ACustomEdit: TCustomEdit); override;
|
class procedure Undo(const ACustomEdit: TCustomEdit); override;
|
||||||
end;
|
end;
|
||||||
@ -1227,6 +1228,17 @@ begin
|
|||||||
EditSetSelLength(ACustomEdit.Handle, NewLength);
|
EditSetSelLength(ACustomEdit.Handle, NewLength);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWin32WSCustomEdit.SetText(const AWinControl: TWinControl;
|
||||||
|
const AText: string);
|
||||||
|
var
|
||||||
|
ACustomEdit: TCustomEdit absolute AWinControl;
|
||||||
|
begin
|
||||||
|
if (ACustomEdit.MaxLength > 0) and (Length(AText) > ACustomEdit.MaxLength) then
|
||||||
|
TWin32WSWinControl.SetText(ACustomEdit, UTF8Copy(AText, 1, ACustomEdit.MaxLength))
|
||||||
|
else
|
||||||
|
TWin32WSWinControl.SetText(ACustomEdit, AText);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
|
class procedure TWin32WSCustomEdit.Undo(const ACustomEdit: TCustomEdit);
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then
|
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then
|
||||||
|
@ -720,7 +720,6 @@ type
|
|||||||
procedure SetSelLength(Val: integer); virtual;
|
procedure SetSelLength(Val: integer); virtual;
|
||||||
procedure SetSelStart(Val: integer); virtual;
|
procedure SetSelStart(Val: integer); virtual;
|
||||||
procedure SetSelText(const Val: string); virtual;
|
procedure SetSelText(const Val: string); virtual;
|
||||||
procedure RealSetText(const Value: TCaption); override;
|
|
||||||
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
|
Loading…
Reference in New Issue
Block a user