Recent

Author Topic: TEDit not firing OnChange when echoMode=emPassword  (Read 2323 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
TEDit not firing OnChange when echoMode=emPassword
« 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?

Zvoni

  • Hero Member
  • *****
  • Posts: 2316
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #1 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
« Last Edit: October 09, 2019, 04:15:45 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #2 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!

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #3 on: October 09, 2019, 04:36:27 pm »
Please file a bugreport.

Bart

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #4 on: October 09, 2019, 04:38:51 pm »
Thanks again!
Bug has been reported: bug 36158

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #5 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)
« Last Edit: October 09, 2019, 07:49:26 pm by Thaddy »
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #6 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?

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #7 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.
« Last Edit: October 09, 2019, 10:47:45 pm by Thaddy »
Specialize a type, not a var.

Zvoni

  • Hero Member
  • *****
  • Posts: 2316
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #8 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
« Last Edit: October 10, 2019, 08:19:41 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #9 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.

Zvoni

  • Hero Member
  • *****
  • Posts: 2316
Re: TEDit not firing OnChange when echoMode=emPassword
« Reply #10 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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018