Is there any way to limit what is acceptable by the EditBox object as input? I mean, accept only numbers or only letters from A to Z, no special characters, etc...
Is there any way to limit what is acceptable by the EditBox object as input? I mean, accept only numbers or only letters from A to Z, no special characters, etc...
Take a look at this
Perfect! Thanks Popcorn!![]()
If you have MMF2 Dev, you can use the Masked Edit object.
I would love to see the example, but the link does not work for me - is there another link?
I have two issues. First is the line inside the box. Before typing any text there's a line like underscore a few characters wide. Second issue is the box cannot be tabbed to like an editbox. No tabstop capability.
I've done some tinkering around in MMF and figured three ways of dealing with limiting numbers:
1. Editbox
2. Masked Edit Object
3. Numeric Up-Down Object
For editbox, you have to basically have the app do what another object or what even Windows normally does for you. First set editbox to read only at start of frame. Then create the condition of:
Upon pressing "0"
Editbox 1 have input focus
Then the action for that set of conditions under the editbox is:
Set Alterable Value A to EditValue("Editbox 1")
Set text Str$(Alterable Value A( "Edit Box 1" ))+"0"
You will have to create this event for all the numbers, 0-9, and changing the value of "0" to that number for each respective event. You will also have to create the same events for use with the number keys on the numbers keypad. The conditions will look like this:
Upon pressing "0 (Num keypad)"
Editbox 1 have input focus
Since it's read only the user cannot backspace if they mistype a number. Now you have to create an event to allow the user to backspace.
The condition for the backspace is:
Upon pressing "Backspace"
Editbox have input focus
Action for condition under Editbox is:
Left$(Edittext$( "Edit Box 1" ), Len(Edittext$( "Edit Box 1" ))-1)
If you choose to use Masked Edit Object, my two beefs are that there's an underscore in the box as well as there appears to be no tabstop ability. My workaround for no tabstop is to create a condition where if the input focus is the edibox before the Masked Edit Object and the tab key is pressed, then set input focus to the Masked Edit Object.
This is very possible, and my example was indeed made with mmf2.
Oldlongdragon, this is the second time in a few days you have asked or said that i am not using mmf2. Please stop doing that. This post is 5 years old, and the link is not working any more.
I might have the example somewhere. I will look for it when i come back home from holiday. It was an effective way of doing this. Kracker's method works, but is not very coder-friendly as you'll ned one event per key. I would use fastloops to scan a list of valid letters.