MATLAB: `isa` not reacting to app’s properties

app designereval errorMATLAB

Hi, I have been trying to find a solution to this problem for a month now. In functions that accept a closing function as an argument, we provide the necessary function's handle as a string to the said function (in my case: uialert). But, in apps, I am unable to make this work. I have tried the following (which was my most clear failure):
I want to stop the UI until the alert box is closed. For this, I tried to follow the example in MATLAB help center on uiwait (link). It didn't work:
Warning: Error while evaluating 'CloseFcn' for dialog.
Unable to resolve the name uiresume(app.UIFigure).
so I tried assigning the part uiwait(app.UIFigure) as a proper function handle
fh = @() uiresume(app.UIFigure);
which I made a public property of the app class.
Then, I ran the app in debug mode, and asked the following:
K>> app.fh
ans =
function_handle with value:
@()uiresume(app.UIFigure)
Yet, backtracing the first error in MATLAB function files, I found out this peculiarity:
K>> isa('app.fh','function_handle')
ans =
logical
0
So, even though app.fh exists and is of type function_handle, isa('app.fh','function_handle') returns false.
Now, this is not the first time I had noticed this. The same problem also occurred when I tried to set a UIAxes figure's YDataSource property inside the app. In the very same manner, the function failed to evaluate an expression like 'app.YDATASOURCENAME' even though there was a public property of the name YDATASOURCENAME in the app, though I diidn't dig in as thoroughly that time so I'm not sure the problem lies in isa like the first example.
So I am guessing isa is somehow incapable (or let's say, unwilling?) to evaluate properties of the app object? Or, maybe there is a more general problem with objects' properties? Either way, does anybody know a way around this problem?

Best Answer

The first parameter to isa() should be the object itself, not a character vector that would be evaluated to give the object.
isa(app.fh, 'function_handle')
In functions that accept a closing function as an argument, we provide the necessary function's handle as a string to the said function
No, that is incorrect. You have three choices:
  1. Provide an actual function handle
  2. Provide a cell array, the first entry of which is an actual function handle
  3. Provide a character vector. The character vector will be eval()'d in the context of the base workspace, and so will not have access to local variables or direct access to object properties . It will also not have access by name to the parameters passed to the callback -- no hObject or event .