guoxinghua5216 发表于 2006-7-27 19:51

可编辑文本框的内容的回调

我用Guide制作了GUI,利用guide我已经制作好了可编辑文本框,请问在M文件里怎么去设置可编辑文本框,怎么将输入到可编辑文本框里的内容回调到untitled_OpeningFcn中去?谢谢~~~

lbchina860 发表于 2006-8-1 08:54

对可编辑框生成一个调用程序就行!

雨路的梦 发表于 2006-8-1 15:03

文本框edit_H
.M文件中有如下代码:

function edit_H_CreateFcn(hObject, eventdata, handles)%创建
% hObject    handle to edit_H (see GCBO)
% eventdatareserved - 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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function edit_H_Callback(hObject, eventdata, handles)%输入的时候的回调函数
% hObject    handle to edit_H (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit_H as text
%      str2double(get(hObject,'String')) returns contents of edit_H as a double
edit_H = str2double(get(hObject, 'String'));
if isnan(edit_H)
    set(hObject, 'String', 0);
    errordlg('输入必须是数字','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit_H = edit_H;                        
setappdata(gcbf, 'metricdata', data);      写好后数据保存在:data.edit_H
页: [1]
查看完整版本: 可编辑文本框的内容的回调