Package: gtk

Function gtk-current-event

Lambda List

gtk-current-event ()

Return Value

A copy of the current gdk-event instance, or nil if there is no current event.

Details

Obtains a copy of the event currently being processed by GTK.

For example, if you are handling a "clicked" signal, the current event will be the gdk-event-button event that triggered the "clicked" signal.

Example

In this example the function gtk-current-event is used in a signal handler to check for a button press event. This code is part of the GTK demo for popovers.
(g-signal-connect calendar "day-selected"
    (lambda (calendar)
      (let ((event (gtk-current-event)))
        (when (eq :button-press (gdk-event-type event))
          (multiple-value-bind (x y)
              (gdk-window-coords-to-parent (gdk-event-window event)
                                           (gdk-event-button-x event)
                                           (gdk-event-button-y event))
            (let ((rect (gtk-widget-allocation calendar)))
              (setf (gdk-rectangle-x rect)
                    (- (truncate x) (gdk-rectangle-x rect)))
              (setf (gdk-rectangle-y rect)
                    (- (truncate y) (gdk-rectangle-y rect)))
              (setf (gdk-rectangle-width rect) 1)
              (setf (gdk-rectangle-height rect) 1)
              (let ((popover (create-popover calendar
                                             (make-instance 'gtk-entry)
                                             :bottom)))
                (setf (gtk-popover-pointing-to popover) rect)
                (gtk-widget-show popover))))))))    
 

See also

2020-8-22