LCL: tried to fix EchoMode and PasswordChar (bug #7924)

git-svn-id: trunk@10310 -
This commit is contained in:
vincents 2006-12-06 20:04:45 +00:00
parent 75f42392b4
commit fcef497c0f
2 changed files with 21 additions and 9 deletions

View File

@ -274,9 +274,14 @@ end;
procedure TCustomEdit.SetPasswordChar(const AValue: Char);
begin
if FPasswordChar=AValue then exit;
FPasswordChar:=AValue;
if FPasswordChar=#0 then
EchoMode:=emNormal;
case FPasswordChar of
#0: EchoMode := emNormal;
' ': EchoMode := emNone;
else
EchoMode:=emPassword;
end;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).SetPasswordChar(Self, AValue);
end;
@ -288,11 +293,20 @@ end;
------------------------------------------------------------------------------}
procedure TCustomEdit.SetEchoMode(Val : TEchoMode);
begin
if (Val <> FEchoMode) then begin
FEchoMode:= Val;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).SetEchoMode(Self, Val);
if FEchoMode=Val then exit;
FEchoMode:= Val;
case FEchoMode of
emNormal :
PasswordChar := #0;
emPassWord :
if (PasswordChar=#0) or (PasswordChar=' ')
then PasswordChar := '*';
emNone :
PasswordChar := ' ';
end;
if HandleAllocated then
TWSCustomEditClass(WidgetSetClass).SetEchoMode(Self, Val);
end;
{------------------------------------------------------------------------------

View File

@ -858,10 +858,8 @@ begin
end;
class procedure TWin32WSCustomEdit.SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode);
const
PassWordChar : array[TEchoMode] of char = (#0, ' ','*');
begin
ACustomEdit.PasswordChar := PassWordChar[NewMode];
// nothing to do, SetPasswordChar will do the work
end;
class procedure TWin32WSCustomEdit.SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer);