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

 채택된 답변

Voss
Voss 2022년 6월 6일
편집: Voss 2022년 6월 6일

0 개 추천

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

jon gorecki
jon gorecki 2022년 6월 27일
thank you
Voss
Voss 2022년 6월 27일
You're welcome!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 6월 6일

댓글:

2022년 6월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by