On Fri, Jun 10, 2011 at 10:37 AM, <os...@simsassociates.co.uk> wrote:
> I have a currency field where the user enters a number such as "245.32". > The Edit control allows a "NUMBER" style that allows only numeric digits - > but does not allow a decimal point. So it's no use in this case. Yeah, that's annoying isn't it. <grin> That is operating system behavior by the way, not something ooDialog can control. > What is the best way to prevent the user from entering any characters other > than the ten digits and a decimal point into an Edit control? You need to connect one of the edit control notifications, from section 3.7.18: UPDATE The text has been altered. This notification is sent before the screen is updated. contrast that with this event: CHANGE The text has been altered. This notification is sent after the screen has been updated. You'll get a notification for each character typed. In your event handler you get the text from the edit control and see if it has a character in it that you are not allowing. (Don't forget that the character typed can be in the middle of the text, depends on where the cursor was when the user typed.) If so you change the text back to what you want. Now here is where you are going to have to experiment somewhat. The MSDN documentation is not very clear on what is going to happen. It may be that if you change the text in the edit control in the UPDATE event, it won't make any difference. (Because the MSDN doc says the edit control has already formatted the text.) It may be that if you change the text in the CHANGE event, the old text still shows, (because the screen is already updated.) It may be that the text changes, but you get some annoying flicker. My first approach would be to try the UPDATE event and see what happens. There is another annoying thing here. What if the user copy and pastes in text? You'll have to test. You may not get an event notification for that. I'm interested in what you come up with. I remember I had trouble using an up-down control and preventing a user from pasting in non-numeric text in an up-down control that was supposed to be numbers only, but with values like 1.1, 1.2, 1.3, etc.. -- Mark Miesfeld ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Oorexx-users mailing list Oorexx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-users