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:
luiz 2009-12-23 16:03:12 +00:00
parent abdf00ce23
commit ab2a0ee728
3 changed files with 12 additions and 14 deletions

View File

@ -391,19 +391,6 @@ begin
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;
------------------------------------------------------------------------------}

View File

@ -174,6 +174,7 @@ type
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: 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;
end;
@ -1227,6 +1228,17 @@ begin
EditSetSelLength(ACustomEdit.Handle, NewLength);
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);
begin
if not WSCheckHandleAllocated(ACustomEdit, 'Undo') then

View File

@ -720,7 +720,6 @@ type
procedure SetSelLength(Val: integer); virtual;
procedure SetSelStart(Val: integer); virtual;
procedure SetSelText(const Val: string); virtual;
procedure RealSetText(const Value: TCaption); override;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;