Lazarus

Programming => Widgetset => Cocoa => Topic started by: Hansaplast on October 09, 2019, 04:08:48 pm

Title: TEDit not firing OnChange when echoMode=emPassword
Post by: Hansaplast on October 09, 2019, 04:08:48 pm
I'm not sure if this is expected behavior or not;


When using a TEdit to enter a password, the "OnChange" event never fires when "echoMode" is set to "emPassword".


The "OnKeyUp" event does fire just fine, so I use this as a workaround right now.


As I'm not sure if this is a bug or expected behavior, I figured I'll just ask here in the forum before reporting it as a bug.
Can anyone confirm either?
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Zvoni on October 09, 2019, 04:13:13 pm
Cannot confirm.
Just started a new simple project, put a TEdit and a TLabel on the form, set echomode for Edit1 to emPassword and this as the OnChange-Event
Code: Pascal  [Select]
  1. procedure TForm1.Edit1Change(Sender: TObject);
  2. begin
  3.   label1.caption:=edit1.Text;
  4. end;    
the Label shows my Password in plain text while entering/modifying

EDIT: Upps. Just saw it was in SubForum "Cocoa", sooooo.....-----> No Idea!  :D
I'm on Windows right now
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Hansaplast on October 09, 2019, 04:33:39 pm
Haha, well, that's a good test though!  :D
Now I can guess it's NOT expected behaviour.
I just did the exact same thing under Cocoa and nothing happens when typing in the TEdit.


Thanks!
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Bart on October 09, 2019, 04:36:27 pm
Please file a bugreport.

Bart
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Hansaplast on October 09, 2019, 04:38:51 pm
Thanks again!
Bug has been reported: bug 36158 (https://bugs.freepascal.org/view.php?id=36158)
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Thaddy on October 09, 2019, 07:46:56 pm
OnKeyUp is not really a work-around: It is usually the better choice anyway... ;D 8-) O:-)

But it seems a bug, just remember the above.
(because the other options keep firing all the time and OnKeyUp fires only once per key press)
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: rvk on October 09, 2019, 10:17:38 pm
(because the other options keep firing all the time and OnKeyUp fires only once per key press)
Does the OnChange-event happen all the time? More than the keypress-event???

Yes, it could also happen when you change the text in code (depending on the component) but isn't that what you want in some (or most) cases?
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Thaddy on October 09, 2019, 10:45:58 pm
OnChange fires probably more than OnKeyUp, at least it does so less than OnKeyDown which everybody seems to consider a good choice... O:-) 8-) >:D Which it almost never is except for navigational purposes.
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Zvoni on October 10, 2019, 08:12:50 am
Is OnKeyUp/Down firing when you copy/paste Text into a TEdit?

EDIT: Just tested on Windows: KeyUp/Down fires for Copy/Paste (Probably for the pressing/releasing of CTRL and C/V)
It doesn't fire for KeyPress
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: rvk on October 10, 2019, 09:57:16 am
Is OnKeyUp/Down firing when you copy/paste Text into a TEdit?

EDIT: Just tested on Windows: KeyUp/Down fires for Copy/Paste (Probably for the pressing/releasing of CTRL and C/V)
It doesn't fire for KeyPress
Yes, it's triggered bij the CTRL and V keys.
It is NOT triggered when someone paste it via mouse-actions.
It is also NOT triggered when the TEdit.Text is changed in code.

So if you want to do something when the TEdit.Text changes (keyboard, mouse or in code), you'll need to use OnChange.
Title: Re: TEDit not firing OnChange when echoMode=emPassword
Post by: Zvoni on October 10, 2019, 10:13:26 am
So if you want to do something when the TEdit.Text changes (keyboard, mouse or in code), you'll need to use OnChange.
Agreed. And as the OP posted: OnChange doesn't fire for him when in echomode=emPassword under Cocoa.
The classic experience: You register at a website, you get an E-Mail with your cryptic Password. You copy the password from the E-Mail, and paste it in the Textbox....
Or in OP's case a probable application: TEdit is in password-mode, and while the user enters his password, the OP tries to gauge, how "good" this password is, and he would need OnChange for that