gtkAddCallback             package:RGtk2             R Documentation

_R_e_g_i_s_t_e_r _a_n_d _c_o_n_t_r_o_l _a _f_u_n_c_t_i_o_n _a_s _G_t_k _e_v_e_n_t _h_a_n_d_l_e_r

_D_e_s_c_r_i_p_t_i_o_n:

     *DEPRECATED!! (compatibility wrappers for RGtk 1!)* 

     These functions allow one to register an R expression, call or
     more typically a function as a callback for a Gtk event, and also
     control the activity status of that callback.
     'gtkObjectAddCallback' registers the S expression, call or
     function as a callback or event handler for the specific event
     type with the widget of interest. When the event occurs for this
     widget,  the S "expression" will be invoked.

     The block and unblock functions allow one to temporarily suspend
     and re-enable a callback. When suspended, any calls to the
     function that would normally occur are not invoked.

     'gtkObjectRemoveCallback' allows one to unregister a callback
     using the identifier obtained when call 'gtkObjectAddCallback'.

     'gtkObjectDisconnectCallback' un-registers a callback.

_U_s_a_g_e:

     gtkObjectAddCallback(w, signal, f, data = NULL, object = TRUE, after = TRUE)
     gtkAddCallback(w, signal, f, data = NULL, object = TRUE, after = TRUE)
     gtkObjectBlockCallback(obj, id)
     gtkObjectUnblockCallback(obj, id)
     gtkObjectDisconnectCallback(obj, id)

_A_r_g_u_m_e_n_t_s:

       w: the Gtk object whose events for this signal type are to be
          monitored and reported to us via a call to the function 'f'.

  signal: a string (character vector of length 1) giving the name of
          the signal type. See the Gtk documentation for the 
          particular widget.

     obj: the Gtk object for which we want to block/unblock or
          disconnect the callback.

       f: the S expression, call or function which is to be invoked
          when an event occurs. If this is a call or expression, it is
          simply evaluated and no additional variables (i.e. the Gtk
          object for which the signal was emitted, etc.) are made
          available to it. If the callback is a function, it will be
          called with a single argument which is an external pointer to
          the C-level event object that describes the event.

    data: a value that is passed to the function 'f' when the callback
          is invoked. This can be use to parameterize a callback
          function so that it behaves differently. This is passed as
          the first argument to the function if 'object' is 'TRUE' or
          as the final argument if 'object' is 'FALSE'. If 'f' is an
          expression or a call, 'data' can be an environment. In this
          case, 'f' is evaluated within this environment. This allows
          the code registering the callback to control the scope of the
          evaluation. 

  object: a  logical value indicating whether we want the value given
          in the 'data' argument to be the first argument to the
          callback function and the Gtk object for which the event
          occurs to be the last argument, or vice-versa. This is
          sometimes convenient and is the difference between a call to
          'gtk_signal_connect' and 'gtk_signal_connect_object' at the
          Gtk interface level. This argument is only meaningful if
          'data' is not missing as no data argument is passed to the
          callback if it is not supplied. 

   after: a logical value indicating whether  to invoke this
          user-defined handler after the signal, or to let the signal's
          default behavior preside (i.e. depending on GTK_RUN_FIRST and
          GTK_RUN_LAST). This influences which signal gets to return a
          value to the event source which can be useful. If the return
          value is 'void', this rarely matters and one can accept the
          default. 

      id: 

_D_e_t_a_i_l_s:

     The S function is invoked by a generic C-level event  handler that
     makes the call to the S function. That function is stored in
     user-level data for the widget. The call provides one argument
     which is a reference to the C event instance.

_V_a_l_u_e:

     'gtkObjectAddCallback' returns an object of class 'CallbackID'
     that provides a unique identifier for the Gtk-level handler. This
     is an integer value whose name attribute gives the name of the
     signal. This object can be used to suspend (block), remove
     (disconnect) and reactivate (unblock) a callback.

     The other functions return a logical value indicating if they were
     succesful or else result in an error.

_N_o_t_e:

     THIS STUFF IS VERY OLD AND DEPRECATED (compatibility wrappers for
     RGtk 1)

     This is an extra-ordinarily early release  intended to encourage
     others to contribute code, etc.

_A_u_t_h_o_r(_s):

     Duncan Temple Lang

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www.gtk.org> <URL: http://www.omegahat.org/RGtk>

_S_e_e _A_l_s_o:

     'gtkButton'

_E_x_a_m_p_l_e_s:

       if (gtkInit()) {
         w <- gtkWindow(show = FALSE)  
         b <- gtkButton("Hit me")
         w$add(b)
         w$show()
         gtkAddCallback(b, "clicked", function(w) {
           help.start();
           TRUE
         })
       }

