Recent

Author Topic: Maskedit usage problems  (Read 2588 times)

szlbz

  • New Member
  • *
  • Posts: 20
Maskedit usage problems
« on: May 30, 2022, 10:29:32 am »
Linux (raspberry OS and other systems with Chinese) uses maskedit and other controls with editmask. When the mask contains / or: (9999/99/; 1; \u) Garbled code occurs during form design, and the compiled program runs normally.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Maskedit usage problems
« Reply #1 on: May 30, 2022, 11:04:51 am »
The '/' is supposed to be replaced with DefaultFormatSettings.DateSeparator.
The IDE may have problems with that on your Pi?
Just guessing.

Whay happens if you change '/' by either '\/' (escape it with a backslash, if you want a literal '/') or e.g. by '-'?

Bart

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #2 on: May 30, 2022, 01:24:48 pm »
The '/' is supposed to be replaced with DefaultFormatSettings.DateSeparator.
The IDE may have problems with that on your Pi?
Just guessing.

Whay happens if you change '/' by either '\/' (escape it with a backslash, if you want a literal '/') or e.g. by '-'?

Bart
The same problem occurs when using Ubuntu 20.04.4 LTS、LMDE 5 Elsie. It is normal to use other characters
« Last Edit: May 30, 2022, 01:30:10 pm by szlbz »

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #3 on: May 30, 2022, 01:26:07 pm »
use lazarus 2.2.2

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Maskedit usage problems
« Reply #4 on: May 30, 2022, 05:52:33 pm »
Please report in the bugtracker (with screenshots).

Bart

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #5 on: May 31, 2022, 04:02:42 am »
Hello  Bart,由于是设计时的显示Bug,debug不了IDE Bug,不过发现是MaskEdit.pp的function TCustomMaskEdit.ClearChar(Position : Integer) : TUtf8Char;
Because it is a design time display bug, the IDE bug cannot be debugged, but it is found in maskedit Function tcustommaskedit Clearchar (position: integer): tutf8char;
Code: Pascal  [Select][+][-]
  1. function TCustomMaskEdit.ClearChar(Position : Integer) : TUtf8Char;
  2. begin
  3.   //For Delphi compatibilty, only literals remain, all others will be blanked
  4.   case GetMask(Position).MaskType Of
  5.     {Char_Space               : Result := #32; //FSpaceChar?; //not Delphi compatible, see notes above}
  6.     Char_HourSeparator        : Result := DefaultFormatSettings.TimeSeparator;//<---
  7.     Char_DateSeparator        : Result := DefaultFormatSettings.DateSeparator;//<----
  8.     Char_IsLiteral            : Result := FMask[Position].Literal; //No need to use GetMask, FMask[Position] already has been validated
  9.     otherwise
  10.       Result := FSpaceChar;
  11.   end;
  12. end;
  13.  
modi:
Code: Pascal  [Select][+][-]
  1.     Char_HourSeparator        : Result := ':';//DefaultFormatSettings.TimeSeparator;
  2.     Char_DateSeparator        : Result := '/';//DefaultFormatSettings.DateSeparator;
  3.  
然后重新编译lazarus,设计时显示就正常了,不清楚为什么设计时DefaultFormatSettings.DateSeparator为什么会出现问题。
Then recompile Lazarus, and the design time display will be normal. It is not clear why there are problems in the design time.
thanks!
« Last Edit: May 31, 2022, 05:40:08 am by szlbz »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Maskedit usage problems
« Reply #6 on: May 31, 2022, 10:13:42 am »
That is not a fix but a workaround for your specific problem.
As by desing '/' and ':' have special meaning in TMaskEdit and must be replaced with DateSeparator and TimeSeparator respectively in the text.

The IDE can be debugged as wel: open the lazarus.lpi project in Lazarus, build and run it.
(OK, sounds easy, but it's really not that simple).

As asked before: please file a bugreport in the bugtracker.

Bart

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #7 on: May 31, 2022, 10:49:07 am »
yes,That is not a fix。

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #8 on: June 01, 2022, 05:49:27 am »
IDE debugging is difficult. I use another method to temporarily solve my problem. Open ide/lazarus.pp, add 2 lines
ide调试有难度,采用另一种方法暂时解决我的问题,打开ide/lazarus.pp, 添加2行
Code: Pascal  [Select][+][-]
  1. {$I revision.inc}
  2. {$R lazarus.res}
  3. {$R ../images/laz_images.res}
  4.  
  5. begin
  6.   Max_Frame_Dump:=32; // the default 8 is not enough
  7.   DefaultFormatSettings.DateSeparator:='-';//2022.6.1  修复mask字符串包含/:时乱码的Bug
  8.   DefaultFormatSettings.TimeSeparator:=':';//2022.6.1  修复mask字符串包含/:时乱码的Bug
  9.  
« Last Edit: June 01, 2022, 05:59:07 am by szlbz »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Maskedit usage problems
« Reply #9 on: June 01, 2022, 11:08:14 am »
Again: please open a ticket in the bugtracker.
Then at least somebody familiar with the IDE and the widgetset involved can have a look at it.
It's your only chace of getting this fixed properly.

Bart

szlbz

  • New Member
  • *
  • Posts: 20

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #11 on: June 02, 2022, 10:01:56 am »
刚debug发现是fpc 单元fpcsrc/packages/rtl-extra/src/unix/clocale.pp引起的,按以下方法修改就可以返回正确的分隔字符。
It has just been found in the debug that it is caused by the fpcsrc/packages/rtl-extra/src/unix/clocale.pp of the FPC unit,
modify: function FindSeparator(const s: string; Def: char): char;
can return the correct separator character.
Code: Pascal  [Select][+][-]
  1.   function FindSeparator(const s: string; Def: char): utf8char;
  2.   var
  3.     i: integer;
  4.     ss:string;
  5.   begin
  6.     FindSeparator := Def;
  7.     i := Pos('%', s);
  8.     if i=0 then
  9.       Exit;
  10.     inc(i);
  11.     SkipModifiers(s, i);
  12.     inc(i);
  13.     //if i<=Length(s) then
  14.     //  FindSeparator:=s[i];
  15.     if i<=Length(s) then
  16.       ss:=UTF8Copy(s,i,1);
  17.     if (ss='年') or (ss='月') or (ss='日') then
  18.       FindSeparator :='-'
  19.     ELSE
  20.       if (ss='时') or (ss='分') or (ss='秒') then
  21.         FindSeparator :=':'
  22.     else
  23.       FindSeparator:=s[i];
  24.   end;
  25.  
« Last Edit: June 02, 2022, 10:50:18 am by szlbz »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Maskedit usage problems
« Reply #12 on: June 02, 2022, 12:09:57 pm »
Ok, if the bug is in FPC, then file a bugreport in the FPC bugtracker please.

Bart

szlbz

  • New Member
  • *
  • Posts: 20
Re: Maskedit usage problems
« Reply #13 on: June 02, 2022, 01:09:06 pm »
Ok, if the bug is in FPC, then file a bugreport in the FPC bugtracker please.

Bart
https://gitlab.com/freepascal.org/fpc/source/-/issues/39756

 

TinyPortal © 2005-2018