View Issue Details

IDProjectCategoryView StatusLast Update
0014771LazarusIDEpublic2009-11-23 11:48
ReporterBart Broersma Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSSuse Linux 
Product Version0.9.29 (SVN) 
Target Version1.0.0Fixed in Version0.9.29 (SVN) 
Summary0014771: Property editor for MaskEdit: some issues
DescriptionIf in OE you set EditMask (for a MaskEdit) to a value that has no MaskFieldSeparator (like "999.999" then click the ellipsis to open the propertyeditor, SplitMask will set SaveLiterals to False, when in fact it should be true.

SaveLiterals should only be false (Delphi compatibility) if MaskNoSave is specified in the second maskfield.
So also an editmask like "ccc;9;_" should set SaveLiterals to True.
(Quoted from http://docwiki.embarcadero.com/VCL/en/MaskUtils.TEditMask:
"A 0 in the second field indicates that literals should not be included, any other character indicates that they should be included. The character that indicates whether literals should be included can be changed in the Edit Mask property editor, or programmatically by changing the MaskNoSave typed constant.")


Very, very minor detail:
If you leave EditMask in OE blank, then open property editor, InputMaskEdit has ";0;_" in it (the 0 is wrong, see above). In this case shouldn't it better be blank as well (it looks rather silly)?


Finally, when the form (propertyeditor) is shown, the InputMaskLabel, SampleMasksLabel, CharacterForBlanksLabel, SaveLiteralCheckBox and LoadSampleMaskButton are not visible (on GTK2/Linux, I did not yet test other widgetsets).
TagsNo tags attached.
Fixed in Revision22712
LazTarget1.0
WidgetsetGTK 2
Attached Files

Activities

2009-10-10 17:45

 

maskproped.png (15,019 bytes)   
maskproped.png (15,019 bytes)   

Bart Broersma

2009-10-10 17:48

developer   ~0031248

The attached maskproped.png shows the missing labels, checkbox and button.
I thought it might be related to the IDE language (Dutch in my case, so I switched to English -> no difference.

The Button and checkbox (but not the labels) become visible when the mouse moves over them.

In win32 the form looks OK.

Bart Broersma

2009-11-18 13:47

developer   ~0032248

Last edited: 2009-11-18 22:54

Attached diff should fix the first and second issue.

I also changed the hardcoded ';' and '_' with MaskFieldseparator and DefaultBlank where appropriate.
Also it now uses the same algorithm as TMaskedit does for splitting the mask and extracting SaveLiterals and BlankChar, where it checks for the occurrence of cMask_SpecialChar before the MaskFieldSeparator.

I opened a new issue for the "disappearing controls" in 0015134

So, if agreed upon this patch, this issue can then be resolved.

2009-11-18 22:50

 

maskpropedit.pas.diff (3,362 bytes)   
Index: maskpropedit.pas
===================================================================
--- maskpropedit.pas	(revision 22593)
+++ maskpropedit.pas	(working copy)
@@ -187,45 +187,49 @@
 
 procedure TMaskEditorForm.CharactersForBlankEditChange(Sender: TObject);
 var
-  I:integer;
-  S1:string;
+  S:string;
+  SL: Boolean;
+  BC: Char;
 begin
-  S1:=InputMaskEdit.Text;
-  if (CharactersForBlanksEdit.Text<>'') then
+  SplitMask(InputMaskEdit.Text, S, SL, BC);
+  if (CharactersForBlanksEdit.Text<>'') and (Length(S) > 0) then
     begin
-    I:=NPos(';', S1, 2);
-    if (I>0) and (I<Length(S1)) then
-      begin
-      S1[i+1]:=CharactersForBlanksEdit.Text[1];
-      InputMaskEdit.Text:=S1;
-      end
+      BC := CharactersForBlanksEdit.Text[1];
+      if SL then InputMaskEdit.Text:=S + MaskFieldSeparator + '1' + MaskFieldSeparator + BC
+        else InputMaskEdit.Text:=S + MaskFieldSeparator + MaskNoSave + MaskFieldSeparator + BC;
+    end
     else
       ReConstructEditMask
-    end;
 end;
 
 Function TMaskEditorForm.SplitMask(AMask :  String; Out MaskText : String; Out SaveLiterals : Boolean; Out BlankChar : Char) : Boolean;
-
-Var
-  P : Integer;
-
 begin
   Result:=False;
-  P:=Pos(';',AMask);
-  If (P=0) then
-    P:=Length(AMask)+1;
-  MaskText:=Copy(AMask,1,P-1);
-  Delete(AMask,1,P);
-  P:=Pos(';',AMask);
-  Result:=(P>0);
-  If Not Result then
-    P:=Length(AMask)+1;
-  SaveLiterals:=StrToIntDef(Copy(AMask,1,P-1),0)=1;
-  Delete(AMask,1,P);
-  If Length(AMask)>0 then
-    BlankChar:=AMask[1]
-  else
-    BlankChar:='_';
+  //Code modified to use same logic as in TCustomMaskEdit
+  BlankChar := DefaultBlank;
+  SaveLiterals := True;
+  if (Length(AMask) >= 4) and (AMask[Length(AMask)-1] = MaskFieldSeparator) and
+     (AMask[Length(AMask)-3] = MaskFieldSeparator) and
+     (AMask[Length(AMask)-2] <> cMask_SpecialChar) and
+     //Length = 4 is OK (AMask = ";1;_" for example), but if Length > 4 there must be no escape charater in front
+     ((Length(AMask) = 4) or ((Length(AMask) > 4) and (AMask[Length(AMask)-4] <> cMask_SpecialChar))) then
+  begin
+    BlankChar := AMask[Length(AMask)];
+    SaveLiterals := (AMask[Length(AMask)-2] <> MaskNosave);
+    Result := True;
+    System.Delete(AMask,Length(AMask)-3,4);
+  end
+  //If not both SaveLiterals and BlankChar are specified, then see if only SaveLiterals is specified
+  else if (Length(AMask) >= 2) and (AMask[Length(AMask)-1] = MaskFieldSeparator) and
+          //Length = 2 is OK, but if Length > 2 there must be no escape charater in front
+          ((Length(AMask) = 2) or ((Length(AMask) > 2) and (AMask[Length(AMask)-2] <> cMask_SpecialChar))) then
+  begin
+    SaveLiterals := (AMask[Length(AMask)] <> MaskNoSave);
+    Result := True;
+    //Remove this bit from Mask
+    System.Delete(AMask,Length(AMask)-1,2);
+  end;
+  MaskText := AMask;
 end;
 
 Function TMaskEditorForm.ConstructEditmask : String;
@@ -239,7 +243,10 @@
   SplitMask(InputMaskEdit.Text,S,L,B);
   If (CharactersForBlanksEdit.Text<>'') then
     B:=CharactersForBlanksEdit.Text[1];
-  Result:=Format('%s;%d;%s',[S,ord(SaveLiteralCheckBox.checked),B]);
+  if (Length(S) = 0) then
+    Result := ''
+  else
+    Result:=Format('%s'+MaskFieldSeparator+'%d'+MaskFieldSeparator+'%s',[S,ord(SaveLiteralCheckBox.checked),B]);
 end;
 
 procedure TMaskEditorForm.ReConstructEditmask;
maskpropedit.pas.diff (3,362 bytes)   

Paul Ishenin

2009-11-23 05:09

manager   ~0032359

Thanks, applied. Please close.

Issue History

Date Modified Username Field Change
2009-10-10 01:44 Bart Broersma New Issue
2009-10-10 01:44 Bart Broersma LazTarget => -
2009-10-10 01:44 Bart Broersma Widgetset => GTK 2
2009-10-10 17:45 Bart Broersma File Added: maskproped.png
2009-10-10 17:48 Bart Broersma Note Added: 0031248
2009-10-14 12:40 Bart Broersma Description Updated
2009-10-20 21:37 Vincent Snijders LazTarget - => 1.0
2009-10-20 21:37 Vincent Snijders Status new => acknowledged
2009-10-20 21:37 Vincent Snijders Target Version => 1.0.0
2009-11-18 13:43 Bart Broersma Status acknowledged => assigned
2009-11-18 13:43 Bart Broersma Assigned To => Bart Broersma
2009-11-18 13:44 Bart Broersma File Added: maskpropedit.pas.diff
2009-11-18 13:47 Bart Broersma Note Added: 0032248
2009-11-18 22:49 Bart Broersma File Deleted: maskpropedit.pas.diff
2009-11-18 22:50 Bart Broersma File Added: maskpropedit.pas.diff
2009-11-18 22:53 Bart Broersma Note Edited: 0032248
2009-11-18 22:54 Bart Broersma Note Edited: 0032248
2009-11-23 05:09 Paul Ishenin Fixed in Revision => 22712
2009-11-23 05:09 Paul Ishenin Status assigned => resolved
2009-11-23 05:09 Paul Ishenin Fixed in Version => 0.9.29 (SVN)
2009-11-23 05:09 Paul Ishenin Resolution open => fixed
2009-11-23 05:09 Paul Ishenin Note Added: 0032359
2009-11-23 11:48 Bart Broersma Status resolved => closed