Function: widget-button-click

widget-button-click is an interactive and byte-compiled function defined in wid-edit.el.gz.

Signature

(widget-button-click EVENT)

Documentation

Invoke the button that the mouse is pointing at.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/wid-edit.el.gz
(defun widget-button-click (event)
  "Invoke the button that the mouse is pointing at."
  (interactive "e")
  (if (widget-event-point event)
      (let* ((mouse-1 (memq (event-basic-type event) '(mouse-1 down-mouse-1)))
	     (pos (widget-event-point event))
	     (start (event-start event))
             (button (get-char-property
		      pos 'button (and (windowp (posn-window start))
				       (window-buffer (posn-window start))))))

	(when (or (null button)
                  (widget-button--check-and-call-button event button))
	  (let ((up t)
                command)
	    ;; Mouse click not on a widget button.  Find the global
	    ;; command to run, and check whether it is bound to an
	    ;; up event.
	    (if mouse-1
		(cond ((setq command	;down event
			     (lookup-key widget-global-map [down-mouse-1]))
		       (setq up nil))
		      ((setq command	;up event
			     (lookup-key widget-global-map [mouse-1]))))
	      (cond ((setq command	;down event
			   (lookup-key widget-global-map [down-mouse-2]))
		     (setq up nil))
		    ((setq command	;up event
			   (lookup-key widget-global-map [mouse-2])))))
	    (when up
	      ;; Don't execute up events twice.
	      (while (not (widget-button-release-event-p event))
		(setq event (read--potential-mouse-event))))
	    (when command
	      (call-interactively command)))))
    (message "You clicked somewhere weird.")))