I want to make an editbox in a MATLAB GUI which will only allow numbers or only allow letters to be typed into it. Is this possible?
Type guide in command window. A new GUI dialog box will appear. In the dialog box you will select the existing GUI project. To to the tab and you will find the gui file which you want to edit.
x = input( prompt ) displays the text in prompt and waits for the user to input a value and press the Return key. The user can enter expressions, like pi/4 or rand(3) , and can use variables in the workspace. If the user presses the Return key without entering anything, then input returns an empty matrix.
Description: The percent sign is most commonly used to indicate nonexecutable text within the body of a program. This text is normally used to include comments in your code. Some functions also interpret the percent sign as a conversion specifier.
There is no such feature, at least not a documented one.
You could assign a callback that will check the input, but that will happen after the user entered illegal character. Though I don't know how exactly to do it, my guess is that you can use Java GUI.
Another interesting option is to add an ActiveX that will do the job.
Edit: I have found an ActiveX that does the job. Downdload it, register by calling
Regsvr32 NumberBox.ocx
And thein add an ActiveX in Matlab Guide. The name will be NumberBox.NbrTextBox. You can do it by cliking the ActiveX button in Guide:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With