ravedadave Posted June 29, 2020 Share Posted June 29, 2020 Hi, I am trying to count the characters entered into a TUniMemo box as they are typed, All the KeyPress functions do not work correctly, can anyone recommend another way of doing it accurately ? Thanks, Dave. Link to comment Share on other sites More sharing options...
Sherzod Posted June 29, 2020 Share Posted June 29, 2020 10 minutes ago, ravedadave said: I am trying to count the characters entered into a TUniMemo box as they are typed Hi, Sorry, for what purpose do you want to use it? Link to comment Share on other sites More sharing options...
ravedadave Posted June 29, 2020 Author Share Posted June 29, 2020 53 minutes ago, Sherzod said: Hi, Sorry, for what purpose do you want to use it? Hi, Thanks for the reply. So I need to count the characters entered into an TUniMemo (i.e. You have entered 64 characters of 160) it's for sending an SMS Text to let the end user know when they are reaching the length of the maximum text. Link to comment Share on other sites More sharing options...
mierlp Posted June 29, 2020 Share Posted June 29, 2020 Hi, Take a look at my example of sending text messages, I think that's what it is all about Link to comment Share on other sites More sharing options...
Sherzod Posted June 29, 2020 Share Posted June 29, 2020 56 minutes ago, ravedadave said: So I need to count the characters entered into an TUniMemo (i.e. You have entered 64 characters of 160) it's for sending an SMS Text to let the end user know when they are reaching the length of the maximum text. Ok. It is better to use a client-side solution. For example: 1. UniLabel, UniMemo1 2. UniMemo1.ClientEvents.UniEvents: function beforeInit(sender, config) { config.enforceMaxLength = true; config.maxLength = 160; } 3. UniMemo1.ClientEvents.ExtEvents: function keyup(sender, e, eOpts) { MainForm.UniLabel1.setText('You have entered '+ sender.getValue().length +' characters of 160'); } 4. procedure TMainForm.UniFormReady(Sender: TObject); begin UniLabel1.JSInterface.JSCode(#1'.setText(''You have entered ''+'+ UniMemo1.JSName +'.getValue().length + '' characters of 160'');'); end; Link to comment Share on other sites More sharing options...
mierlp Posted June 29, 2020 Share Posted June 29, 2020 procedure TMainForm.UniMemoChange(Sender: TObject); begin uniLabel_Char.Caption := IntToStr(Length(StringReplace(StringReplace(UniMemo. Lines.Text, #10, '', [rfReplaceAll]), #13, '', [rfReplaceAll]))); end; sorry...wrong post Link to comment Share on other sites More sharing options...
ravedadave Posted July 2, 2020 Author Share Posted July 2, 2020 On 6/29/2020 at 11:23 AM, Sherzod said: Ok. It is better to use a client-side solution. For example: 1. UniLabel, UniMemo1 2. UniMemo1.ClientEvents.UniEvents: function beforeInit(sender, config) { config.enforceMaxLength = true; config.maxLength = 160; } 3. UniMemo1.ClientEvents.ExtEvents: function keyup(sender, e, eOpts) { MainForm.UniLabel1.setText('You have entered '+ sender.getValue().length +' characters of 160'); } 4. procedure TMainForm.UniFormReady(Sender: TObject); begin UniLabel1.JSInterface.JSCode(#1'.setText(''You have entered ''+'+ UniMemo1.JSName +'.getValue().length + '' characters of 160'');'); end; Thank You! Very much appreciated, Kind Regards. Dave 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now