I have made a program in appdesigner and I want to prevent to end-user from being able to double-click a button (the button starts a data aquisition routine).
I have tried setting the buttons Interruptible property to 'off' and this works well, however I have another button which the user can click to end the data-aquisition routine early (the stop button), so by setting the Start button to not interruptible then the stop button cannot work.
I have tried a work-around whereby the Start button begins as non-interriptible, and then once pressed and the data-aqusition begins the Start button property will change to Interruptible, however I find that although the property is changed the Stop button will not interrupt it.
My other approach was to disable the Start button once it is pressed (and enable it again once the routine has finished) however the GUI does not refresh very quickly and there is significant time (~few tenths of second) for a double click to be performed.
Any advice would be appreciated

 Réponse acceptée

Voss
Voss le 6 Juin 2022
Modifié(e) : Voss le 6 Juin 2022
Maybe you can try setting a flag, i.e., a variable of class logical, that indicates whether the data acquisition routine is running. Then in the Start button callback, you would return early if that flag is true (i.e., don't start if it's already started).
Maybe something like this:
function StartButton_Callback(app,event)
if app.is_acquisition_running
return
end
app.is_acquisition_running = true;
% begin data acquisition
% ...
% ...
% end data acquisition
app.is_acquisition_running = false;
end
And you would obviously want to set that flag accordingly in the Stop button callback as well, and maybe also check that it is false first, depending on what stopping entails (i.e., (maybe) don't stop if it's already stopped).

2 commentaires

jon gorecki
jon gorecki le 27 Juin 2022
thank you
Voss
Voss le 27 Juin 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by