Need Help with Edit Text box in Matlab GUI ;D
Ältere Kommentare anzeigen
Hi, I've created a GUI using matlab and I have added a Text Box that a user can enter either numbers or text into.
I have made it so a user can enter a value into the text box, E.G '145' and that value will be assigned to a variable which i can the use this variable to do other things.
Also at the moment in the text box i have the text saying input a value. Is there any settings to make this writing disapear/ delete when the edit box is clicked on, because at the moment i have to manually delete this text before i can enter a number.
also is there a way to only let the user input values rather then letters? And also set a limit on what they can enter, eg only values between 20 to 100 will be accepted.
Edit Box Code Shown Below:
function Text_Input_Height_Callback(hObject, eventdata, handles)
% hObject handle to Text_Input_Height (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Text_Input_Height = get(hObject, 'string')
% --- Executes during object creation, after setting all properties.
function Text_Input_Height_CreateFcn(hObject, eventdata, handles)
% hObject handle to Text_Input_Height (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Akzeptierte Antwort
Weitere Antworten (1)
david Landrith
am 1 Apr. 2011
0 Stimmen
use str2double(get(hObject, 'String')) to convert input strings to values
or try
get(hObject, 'Value')
1 Kommentar
jim
am 1 Apr. 2011
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!