App designer callback not evaluating

10 Ansichten (letzte 30 Tage)
James Johnson
James Johnson am 21 Okt. 2020
Bearbeitet: James Johnson am 24 Okt. 2020
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 Kommentare
Mario Malic
Mario Malic am 21 Okt. 2020
Bearbeitet: Mario Malic am 22 Okt. 2020
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 am 24 Okt. 2020
Bearbeitet: James Johnson am 24 Okt. 2020
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by