Reputation: 531
Without using GUIDE how would I get the value of an edit uicontrol after pressing a pushbutton?
Example:
fig = figure;
input = uicontrol(fig, 'Style', 'edit', 'Tag', 'input');
btn = uicontrol(fig, 'Style', 'pushbutton', 'Callback', @obj.test);
Then in my class
methods
function testing(src, event, handles)
msgbox(get(handles.input, 'string'));
end
end
Upvotes: 0
Views: 643
Reputation: 2149
GUI code:
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
Class definition:
classdef testclass
methods
function testing(obj,src, event, handles)
msgbox(get(handles, 'string'));
end
end
end
Upvotes: 2