[Top][All Lists]

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

RE: Catching Figure close button - callbacks not running?

From: Richardson, Anthony
Subject: RE: Catching Figure close button - callbacks not running?
Date: Tue, 29 Jan 2019 18:19:39 +0000

> -----Original Message-----
> From: Help-octave <help-octave-
> address@hidden> On Behalf Of Pavel Hofman
> Sent: Tuesday, January 29, 2019 3:50 AM
> To: address@hidden
> Subject: Re: Catching Figure close button - callbacks not running?
> Dne 28. 01. 19 v 20:53 Pavel Hofman napsal(a):
> > Hi,
> >
> > Please is there a way to assign a hook to the figure close button? I
> > understand the button is provided by the window manager of my OS but
> > please can I handle it in octave?
> >
> > I cannot use uiwait since my main thread cycles reading incoming
> > zeromq messages and uiwait() rounds timeout to whole seconds.
> >
> > If I could run a callback when the windows close button is pushed, I
> > could arrange for quitting the reading loop at next iteration.
> >
> I think the problem is my main thread does not finish and no GUI callbacks
> are run. No pushbutton callbacks are executed. My thread ends with infinite
> cycle - reading zeromq messages.
> Please what would be a recommended way to solve such problem? Would
> running the GUI thread and the reading thread side by side with parallel
> package help? The message reading loop thread must have access to the GUI
> handles currently stored in a global struct.
> Thanks a lot for help with principles of using the octave UI elements.
> Best regards,
> Pavel.

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'))

This will display 'bye bye' in the command window when the window is deleted.

Tony Richardson

reply via email to

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