I try to implement a fall back function in my gui that updates a waitbar. I pass the function handle into the function which loads the images. The fallback itself works, but I do not get the handle to the waitbar.
function z_WaitBarUpdate(value, maxValue)
handles=guidata(handles.output); % <-- fails because handles is unknown
if ishandle(handles.waitbar.handle)
waitbar(value/maxValue,handles.waitbar.handle,handles.waitbar.text);
end
I call the function with the handle with this code
hWait = waitbar(0,'1','Name','Reading calibration file ...');
cleanupWaitbar = onCleanup( @()( delete( hWait )));
handles.waitbar.handle = hWait;
handles.waitbar.text = 'reading subset of stack ...';
readCalibrationImage( handles , @z_WaitBarUpdate);
any idea how to access the waitbar handle in my callback?
I don't typcially use most o the features you are using, I'm not a Matlab GUI guy. But, I think this would work.
Change
to
Change
to
First, this defines a third input to the update function, to handle the input that you are missing. If
handles
is not passed in then it will not be available to the function. Then, after thehandles
structure has been created, this creates an anonymous function with the purpose of defining the third input, while allowing the first two inputs to be defined later, when the function is actually called.