App designer callback not evaluating

조회 수: 9 (최근 30일)
James Johnson
James Johnson 2020년 10월 21일
편집: James Johnson 2020년 10월 24일
I think the problem is that a "valueChanged" callback is not being evaluated when the value changes. How can I force callbacks to be evaluated when promised (it might be a java issue since it goes away after restarting MATLAB? I might need to somehow clear that?)
Here is the problem description
I have a gui I exported from app designer. I wrote a simple callback after exporting. When a user clicks a check box labeled "Monkey GIFs" some buttons on the GUI are set to invisible and are replaced with images. The images have been there the whole time but are set to invisible by default. All the check box does is toggle the visibility and ensure the buttons and the images have opposite visibility.
However, the changes in visibility do not render until after the user interacts with some other feature. I put a "drawnow" in the checkbox callback so I think the problem is that the callback itself is not being evaluated until the next click. The problem is intermittent, and doesn't occur on the first use after restarting MATLAB.
Here is how I create the checkbox
app.MonkeyGIFsCheckBox = uicheckbox(app.AutoBackupTab);
app.MonkeyGIFsCheckBox.ValueChangedFcn = createCallbackFcn(app, @MonkeyGIFsCheckBoxValueChanged, true);
app.MonkeyGIFsCheckBox.Text = 'Monkey GIFs';
app.MonkeyGIFsCheckBox.Position = [29 75 92 22];
app.MonkeyGIFsCheckBox.Value = false;
Here is how I wrote the callback
% Value changed function: MonkeyGIFsCheckBox
function MonkeyGIFsCheckBoxValueChanged(app, event)
value = app.MonkeyGIFsCheckBox.Value;
if value
app.CloseWithoutBackupImage.Visible='on';
app.CloseWithoutBackupImageLabel.Visible='on';
app.PerformBackupImage.Visible='on';
app.PerformBackupImageLabel.Visible='on';
app.CloseWithoutBackupButton.Visible='off';
app.PerformBackupButton.Visible='off';
else
app.CloseWithoutBackupImage.Visible='off';
app.CloseWithoutBackupImageLabel.Visible='off';
app.PerformBackupImage.Visible='off';
app.PerformBackupImageLabel.Visible='off';
app.CloseWithoutBackupButton.Visible='on';
app.PerformBackupButton.Visible='on';
end
drawnow
end
  댓글 수: 2
Mario Malic
Mario Malic 2020년 10월 21일
편집: Mario Malic 2020년 10월 22일
Edit: italics in my comment is not correct.
This question might be of interest https://uk.mathworks.com/matlabcentral/answers/345697-how-to-add-extra-arguments-to-callback-functions-in-app-designer. It looks like that third argument 'true' doesn't work.
James Johnson
James Johnson 2020년 10월 24일
편집: James Johnson 2020년 10월 24일
Thanks for taking an interest.
It's not an "extra argument". MATLAB's built in app designer put that "true" in there, it looks like a required positional argument. I had nothing to do with it, and don't need to use extra arguments or share data across callbacks.
Hence, it's irrelevant. I just need to get the callback to actually execute. I think it's a java issue. I'm hoping there's some way to "flush" java. Note: I already use "drawnow" which is unhelpful since the callback doesn't get executed until the user clicks some other element.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by