[Lazarus] Edti's password char with bug?

Gerard Visent gerardusmercator at gmail.com
Wed Aug 10 17:21:32 CEST 2011


Hi Martin,

>
> Hm, on my system 158 results in a "z" with some tilde or accent.
>

Same here.


>
> But that is probably the correct behaviour.
>
> For some reason the PassWordchar field accepts an ansi char, rather than a
> utf8 char. So what you will see depends on the codepage of the system on
> which your app is run. Even if it displays fine on your PC, if you ship the
> app, other people will see other chars.
>
> How or why it becomes an * I do not know...
>

I found why, but I can't explain the reason behind the code.
In lcl/interfaces/gtk2/gtk2wsstdctrls :

class procedure TGtk2WSCustomEdit.SetPasswordChar(
  const ACustomEdit: TCustomEdit; NewChar: char);
var
  PWChar: Integer;
  Entry: PGtkEntry;
begin
  if not WSCheckHandleAllocated(ACustomEdit, 'SetPasswordChar') then
    Exit;
  Entry := PGtkEntry(ACustomEdit.Handle);
  if ACustomEdit.EchoMode=emNone then
    PWChar:=0
  else begin
    PWChar:=ord(ACustomEdit.PasswordChar);
    if (PWChar<192) or (PWChar=ord('*')) then
      PWChar:=9679;
  end;
  gtk_entry_set_invisible_char(Entry,PWChar);
end;

Commenting the following lines

  if (PWChar<192) or (PWChar=ord('*')) then
      PWChar:=9679;

allows to display any char. But there must be a reason for this check and
whoever wrote didn't bother writing a comment.

Regards,

Gerard.



>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110810/8014bbb9/attachment-0003.html>


More information about the Lazarus mailing list