Preventing Early User Closing of Application

9 views (last 30 days)
If the application is busy doing its thing, before it goes off and starts can disable the various buttons to prevent trying to start the process a second time or to quit -- but, how to prevent an accidental or otherwise "Alt-F4" or selecting the Close area until it finishes its work and comes back to the UI?

Accepted Answer

Voss
Voss on 29 Dec 2022
Maybe set the CloseRequestFcn to [] when you want to disable closing the application. Then restore the CloseRequestFcn again when closing should be re-enabled.
  3 Comments
Voss
Voss on 1 Jan 2023
Edited: Voss on 1 Jan 2023
I'm not sure what you mean by "Window property".
Setting the figure's CloseRequestFcn to [] prevents closing via Alt-F4, clicking the X button, and using the close() function (unless using close all force), but it does not prevent closing programmatically via delete().
f = figure('CloseRequestFcn',[]);
close(f) % does not delete f
ishandle(f)
ans = logical
1
delete(f) % deletes f
ishandle(f)
ans = logical
0
dpb
dpb on 1 Jan 2023
" what you mean by "Window property"."
Seems like the "X" button would be addressable to set its state similar as to other controls is all...
I grok the callback....thanks.

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!