不使用GUIDE按下按钮后如何获取编辑uicontrol的值?
示例:
fig = figure;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input');
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', @obj.test);
然后在我班上
methods
function testing(src, event, handles)
msgbox(get(handles.input, 'string'));
end
end
答案 0 :(得分:2)
GUI代码:
function gui_test
fig = figure;
obj= testclass;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input','Position',[10 70 100 20]);
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', {@obj.testing,input});
end
班级定义:
classdef testclass
methods
function testing(obj,src, event, handles)
msgbox(get(handles, 'string'));
end
end
end