help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching Figure close button - callbacks not running?


From: pavel
Subject: Re: Catching Figure close button - callbacks not running?
Date: Tue, 29 Jan 2019 20:22:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

Hi Tony,

Dne 29. 01. 19 v 19:19 Richardson, Anthony napsal(a):

Define a callback for the 'DeleteFcn' property of the current figure window (or 
a handle
returned by the figure() function):

    set(gcf, 'DeleteFcn', @(h, e) mycallback(h, e))

The callback will be run when the window is pressed.

Here is a simple (specific) example.  Enter at the command prompt:

    set(gct, 'DeleteFcn' @(h, e) disp('bye bye'))


Thanks a lot! This is what I was looking for, works great.

There was another problem - I did not call drawnow() in the infinite reading the messages. Took me a while to learn that the UI code is single-threaded and drawnow executes the queued callbacks.

Since my callbacks use a lot of pauses and take several secs each, I must either run them in a different thread (parallel?) or rewrite the code to run the callbacks code interleaved with reading the messages. I wonder if people face the same issue and how they tackle it.

Please do you have any idea how to catch the Ctrl+C command from IDE command window so that the figure can be closed automatically when forced-stopping the script in IDE?

I very much appreciate your advice and help.

Best regards,

Pavel.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]