Hello,
I am currently working on a GUI and got stacked at some point. I want to read the value of selected popup element inside its callback to change value of some other GUI component. Below the code that attempts to display the selected element
S.FromBlockPopUp = uicontrol('Style', 'popup',...
'String', ' ',...
'fontsize',10,...
'position',[400 200 100 25],...
'callback',{@update_text,S});
function [] = update_text(varargin)
S = varargin{3};
disp(getCurrentPopupString(S.FromBlockPopUp))
function str = getCurrentPopupString(hh)
list = get(hh,'String');
val = get(hh,'Value');
if iscell(list)
str = list{val};
else
str = list(val,:);
end
After execution I got the error:
Undefined variable "S" or class "S.FromBlockPopUp".
Unfortunately I am not able to read selected value as the struct S does not have a handle to that popup (It was created while adding the callback, hence the callback can't access it).
It seems a bit weird that I can't read it. Do you have any suggestion how it can be solved? Do you know any workarounds?
BR, Michal