TMSFNCEDIT: Set LengthLimit > 0 and reach the limit, no cursor function

At a TTMSFNCEDIT Field I have set LengthLimit to 5.
if At runtime the maximum input length has been reached, the cursor cannot go back in the input field.
I first have to delete min. one character at the end of the input text, than I can use the cursor keys again.

I have set the following values in the component:
LengthLimt := 5;
EditType := etString;

Have already tried it with other EditTypes and also different LengthLimits.

Sorry we are not able to reproduce this, can you provide a sample? Which framework are you using?

I'm using Delphi 11.2 and the TMSFNC Core version 2.8.6.0, with TMSFNCEDIT Version 1.0.3.0 .
I'm creating a new app with only one TMSFNCEdit field. Set the LengthLimit to 5. Enter 5 characters and then try to move the cursor in the field one character to the left. But that is not possible. The cursor stops moving as long as the LengthLimit is reached.

Yes, but which framework? VCL, FMX? Please provide a sample

Hi Pieter,
It is an FMX project. I have attached a DEMO project here in the attachment
Project_TMSFNCEdit.zip (93.8 KB)

I have now created the same as a VCL project. There it works

Your demo project works fine here, is this on Windows or another operating system?

It is windows 10 pro

Is this reproducible with a TEdit? Can you try with the MaxLength property instead?

Hello Pieter,
I have tested it with TEdit (MaxLength=5) and it works fine.
I send you a video that shows the problem with an TMSFNCEdit component.
It's not a perfect locking video, but you can see what I am doing.

I have copied this demo app to different computers with different windows versions.
Everywhere the same result.

can you try with the TTMSFNCEdit . MaxLength property instead?

Hi Pieter,
yes, with "TMSFNCEDIT.MaxLength" it works.

Thx.
I wish you and everyone in the TMS Team a merry christmas and Happy new year.

1 Like

Thanks Andreas!! And the same to you

nfortunately, the error still exists. Delphi 12, Framework FMX and current FNC version. If you set LengthLimit in TTMSFNCEDIT and write everything up to the limit, you can no longer move the cursor to the left, only Backspace works. But the Delete key in the middle of the text should also work! Does not work either. Why replace the MaxLength property with a new property that doesn't work? I have a lot of edit input and don't want to write everything manually with MaxLength in the source code. Please fix the error!

TTMSFNCEdit inherits from TCustomEdit, does the same thing happen with a normal TEdit?

Hi Pieter,
many thanks for the quick reply! With TEdit and MaxLength it works as it should. Not with TTMSFNCEDIT and LengthLimit. It's not a problem with the Android platform, but
with Windows. Tested with Windows 10 and Windows 11. I have sent you a simple test project. Test_TFNCEDIT.zip (77.7 KB)

The problem is not difficult to find:
When the limit is reached, only backspace is allowed.

FMX.TMSFNCEdit

procedure TTMSFNCEdit.KeyDown(var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
...
Original source code, Line 1215:
if (FLengthLimit > 0) and (FixedLength(self.Text) > FLengthLimit) and
(SelLength = 0) and (SelStart < DecimalPos) and (FKeyDown <> KEY_BACK) and (FKeyDown <> ord(FormatSettings.decimalseparator{$IFDEF WEBLIB}[0]{$ENDIF})) and not AllowMin(kch) then
begin
EatKey;
Exit;
end;

Solution (but not very nice):
if (FLengthLimit > 0) and (FixedLength(self.Text) > FLengthLimit) and
(SelLength = 0) and (SelStart < DecimalPos) and (FKeyDown <> KEY_BACK) and (FKeyDown <> KEY_DELETE) and (FKeyDown <> KEY_LEFT) and (FKeyDown <> KEY_Right) and (FKeyDown <> ord(FormatSettings.decimalseparator{$IFDEF WEBLIB}[0]{$ENDIF})) and not AllowMin(kch) then
begin
EatKey;
Exit;
end;

Hi,

Thanks for the feedback, we will investigate this here asap.

You can use TMSFNCEdit1.MaxLength instead.