Search code examples
rgwidgetsrgui

R and gWidgets: Event trigger on close of a widget


I'm currently working on a small GUI based application using gWidgets (RGtk2). I've encountered a question which I was unable to solve by myself using the documentation provided in the gWidgets package:

Is it possible to trigger an event, i.e. a function, when the user clicks on the red cross to close the GUI / widgets/ main window? For usability reasons I don't want to have an extra button though it will definitely work.

PS: I don't think an example is necessary here but if any of you insists I will add one.


Solution

  • Try

    addhandlerdestroy( myWidget, handler = f_exit )
    

    where

    f_exit <- function( h,...
    {
      # your code, maybe simply
      dispose( myWidget )
    }