OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: docsaintly on August 07, 2009, 12:14:05 PM

Title: Feature Request / Workaround for Float validation
Post by: docsaintly on August 07, 2009, 12:14:05 PM
I am working with textboxes and trying to get a real (float) value back. Under the text box properties I can select to restrain the type to integer, string, or autocad number type. Integer obviously doesn't work, I could use a string, but i'd have to somehow be able to compare the text value of the box before and after the edit. This could be done but it would be quite cumbersome (using Set Focus / KillFocus to store a "global" variable for the box to compare). The autocad type doesn't work because I want the user to be able to type 1/16" or 0.0625.

Any ideas?
Title: Re: Feature Request / Workaround for Float validation
Post by: owenwengerd on August 07, 2009, 02:03:38 PM
You can use the TextBox_SetFilter method to set a custom filter when Filter Style is set to 'String'. In addition, you can handle EditChanged or KillFocus to validate the contents.
Title: Re: Feature Request / Workaround for Float validation
Post by: docsaintly on August 07, 2009, 02:14:33 PM
Owen,
   Thanks a lot. I think the (dcl_textboc_setfilter txtCellX "0123456789./" will achieve what I want as far as making sure it's what it should be. However, when I tried the EditChanged and Update events, the value they were giving were the same as the textbox.text value. Maybe my logic is flawed but I thought that the EditChanged or Update method would return the value the user was trying to enter, and the Textbox.text value would be the value before the user changed it. Otherwise, how can I compare the new value to the old unless I set a global to store the text every time it's changed.
Title: Re: Feature Request / Workaround for Float validation
Post by: owenwengerd on August 07, 2009, 02:31:36 PM
Yes, if you need to know what changed, you have to track it yourself. That's why I suggested to just validate in OnKillFocus and not worry about what or how it changed. Internally there is infrastructure to validate before it changes (by using the assigned filter), but there's no simple way to expose that to lisp.
Title: Re: Feature Request / Workaround for Float validation
Post by: docsaintly on August 07, 2009, 03:08:58 PM
Owen,
   Thanks for the advice. The only reason I care about what was in the box before is because if it was in the box it was valid text, so if the user enters invalid text I wanted to revert to that. I guess I can just make it 0.0 and tell the users to make sure they don't put in bad text.