Re: edit text field question
- Posted by Derek Parnell <ddparnell at bigpond.com> Jan 25, 2002
- 455 views
Hi George, ----- Original Message ----- From: <gwalters at sc.rr.com> To: "EUforum" <EUforum at topica.com> Subject: edit text field question > > If you have an editText field with style ES_NUMBER, you cannot enter a > period. This seems a little dumb....Is there a way around this w/o doing my > own enforcement? You are right. The style ES_NUMBER only permits the digits '0' - '9' in an edit field. My guess is that it excludes punctuation because that starts to get too complex for a general routine. Just consider different cultural standards - Europeans use a comma as a decimal marker and those from British heritage use a period. However, using you own enforcement is not difficult using win32lib. Here one way of doing it... -------------- constant NumberChars = "0123456789." procedure NumberOnly(integer self, integer event, sequence params) -- Is this character a valid one? if find(params[1], NumberChars) = 0 then -- No, so tell windows to ignore it. returnValue(-1) end if end procedure -- Set the handler for every edit field that needs this setHandler({editfld1, editfld2, ...etc...}, w32HKeyPress,routine_id("NumberOnly")) -------------- cheers, Derek.