App designer callback not evaluating
조회 수: 9 (최근 30일)
이전 댓글 표시
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
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!