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.
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.
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.
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!
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;