Cristian Peța 103 Posted February 25, 2021 (edited) Customers asked me a long time ago for a feature to be able to introduce the length in inch in "12 3/16" format in a TEdit like control. I've made a component for this but with the new TNumberBox in Delphi 10.4.2 I wonder if this is usual and if there are some components for this in Delphi world? Edited February 25, 2021 by Cristian Peța Share this post Link to post
Guest Posted February 25, 2021 3 hours ago, Cristian Peța said: I wonder if this is usual and if there are some components for this in Delphi world? hi @Cristian Peța if fact, you dont needs (necessary) of a "new" component! in (pratically) all Delphi editons, you have "TMaskEdit" this component/class ask just 3 parts of control the entry: Part1: you use "0" or "9", been "0" to say: entry mandatory! Part2: to say if you desire the "mask" be store with your data on, let say, a table-field, like when using a TDateTime value, you see? Part3: any char to represent (on screen) the values not typed on Edit! in my sample, "\/" it means that "/" not will be typed by user, because it is "part" of the mask! My TMaskEdit have: EditMask = '00 0\/00;0;_' hug Share this post Link to post
Attila Kovacs 629 Posted February 25, 2021 There must be a bug in Delphi as "\/" does not make a literal from "/" but instead converts it to the system's date separator. Buhh. Anyway, what if the user just want to enter 12"? Share this post Link to post
Cristian Peța 103 Posted February 25, 2021 (edited) But if you read the Text property you have "12316". How to transform this into a value? And what if the user want to type "12 15/16" or "123 1/4"? And I have my control that do the job but was wondering if there are some other edit controls for this. Maybe it's not so common. Edited February 25, 2021 by Cristian Peța Share this post Link to post
Cristian Peța 103 Posted February 25, 2021 Now I see there is an TMaskEdit.EditText property. But it looks odd if you have a mask like this "0000 00\/00;0;_" and want to write only "1 1/2" Share this post Link to post
Guest Posted February 25, 2021 (edited) 2 hours ago, Cristian Peța said: Now I see there is an TMaskEdit.EditText property. But it looks odd if you have a mask like this "0000 00\/00;0;_" and want to write only "1 1/2" just use "0000 00\/00;1;_" to stored the mask with text! there is not problem with use "\/" or any other char like "\X" --> "X" as a "literal value not typed by user as "/" ! it's silly comment! poor baby! if need not type some value, like above, just use "SPACEBAR" to jump to next part of mask! put the "0" (mandatory value) on "first chars on mask" as my sample above! you can put any char as "showed on screen - like my "*" now, include "space or == char(0) using ALT+255 === old code many used on D.O.S. do you remember?" of course, if you dont "want it" on resulted = maskedit.EditText, try "StringReplace()" function to remove all "*" or any other char on string-resulted! StringReplace( maskedit.EditText, "*", '', [ options = replace all, and, ignore case] using a char different, like me, "*" for screen and ' ' for separate the parts, would be good, in case, using "StringReplace". then, you will preserve the "spaces" if you want it you see? procedure TForm1.Button2Click(Sender: TObject); begin Memo1.Lines.Clear; Memo1.Lines.Add('MaskEdit1.Text = ' + MaskEdit1.Text ); Memo1.Lines.Add('MaskEdit1.EditMask = ' + MaskEdit1.EditMask ); Memo1.Lines.Add('MaskEdit1.EditText = ' + MaskEdit1.EditText ); Memo1.Lines.Add('MaskEdit1.EditText = ' + StringReplace(MaskEdit1.EditText, '*', '', [rfReplaceAll, rfIgnoreCase])); end; hug Edited February 25, 2021 by Guest Share this post Link to post
KodeZwerg 54 Posted February 25, 2021 Nothing against above stuff. Another approach can be usage of TEdit, parse data on your own to get a float as result to work with. Should have a better look, but users must be told somewhere how to enter data that it works. I found this code by Andreas Rejbrand to getting you started. Share this post Link to post
Guest Posted February 25, 2021 (edited) 16 minutes ago, KodeZwerg said: Another approach can be usage of TEdit, parse data on your own to get a float as result to work with. hi @KodeZwerg for sure, there is many others ways, and, TEdit is one for sure! you're right! But TMaskEdit is a "evolution" (if I can say some like that) of TEdit. We should see the "ancestral" of two class! look how many code using "TEdit" and "TMaskEdit" TMaskEdit = class(TCustomMaskEdit) TCustomMaskEdit = class(TCustomEdit) <---- TCustomEdit = class(TWinControl) TWinControl = class(TControl) TControl = class(TComponent) TComponent = class(TPersistent, IInterface, IInterfaceComponentReference) TEdit = class(TCustomEdit) <---- TCustomEdit = class(TWinControl) TWinControl = class(TControl) TControl = class(TComponent) TComponent = class(TPersistent, IInterface, IInterfaceComponentReference) hug Edited February 25, 2021 by Guest Share this post Link to post
Guest Posted February 25, 2021 (edited) put your photo like "DateSepator" and will see the bug bigger that this! insane use of property is a brain-bug too! Edited February 25, 2021 by Guest Share this post Link to post
KodeZwerg 54 Posted February 25, 2021 @emailx45 Sorry that I mentioned that a TEdit looks better. By reading complete thread again, he asked if new Delphi got native stuff to do. He already has its own component so i am out. Share this post Link to post
Guest Posted February 25, 2021 (edited) 20 minutes ago, KodeZwerg said: By reading complete thread again, he asked if new Delphi got native stuff to do. He already has its own component so i am out. no. no. no. It's good have a new opinion or view! you're wellcome me, can be wrong too! dont worry! hug Edited February 25, 2021 by Guest Share this post Link to post
Attila Kovacs 629 Posted February 25, 2021 (edited) 4 hours ago, emailx45 said: insane use of property is a brain-bug too! It will be the system default by default. So in my case it's __ __.__ Looks like a bug in MaskEdit Edited February 25, 2021 by Attila Kovacs Share this post Link to post
Daniel 417 Posted February 25, 2021 folks -- please step down a little and focus on the topic. If you don't want to contribute anything substantive - even for the time being - that's okay. Together, we should be careful not to lapse into personal affronts. Share this post Link to post
Attila Kovacs 629 Posted February 25, 2021 (edited) Yeah, thx. We found a bug in the RTL/VCL and a better way to communicate. I see no offensive material. Edited February 25, 2021 by Attila Kovacs 1 Share this post Link to post
Bernard 18 Posted March 23, 2021 (edited) I have a half baked component that accepts metric or imperial. Half baked because in metric mode it works in mm only In Imperial mode it works in inches only. It does not display fraction format but accepts it so these are all valid input 6'3" 5m23cm 1 1/5M 3 1/2" 3' 1/2" 12ga If anyone wants to help improve the code let me know, and I will stick it on Github. Edited March 23, 2021 by Bernard Share this post Link to post