856 |
|
|
857 |
(defun widget-button-click (event) |
(defun widget-button-click (event) |
858 |
"Invoke the button that the mouse is pointing at." |
"Invoke the button that the mouse is pointing at." |
859 |
(interactive "@e") |
(interactive "e") |
860 |
(if (widget-event-point event) |
(if (widget-event-point event) |
861 |
(let* ((pos (widget-event-point event)) |
(let* ((pos (widget-event-point event)) |
862 |
(button (get-char-property pos 'button))) |
(start (event-start event)) |
863 |
|
(button (get-char-property |
864 |
|
pos 'button (and (windowp (posn-window start)) |
865 |
|
(window-buffer (posn-window start)))))) |
866 |
(if button |
(if button |
867 |
;; Mouse click on a widget button. Do the following |
;; Mouse click on a widget button. Do the following |
868 |
;; in a save-excursion so that the click on the button |
;; in a save-excursion so that the click on the button |
869 |
;; doesn't change point. |
;; doesn't change point. |
870 |
(save-selected-window |
(save-selected-window |
871 |
|
(select-window (posn-window (event-start event))) |
872 |
(save-excursion |
(save-excursion |
873 |
(mouse-set-point event) |
(goto-char (posn-point (event-start event))) |
874 |
(let* ((overlay (widget-get button :button-overlay)) |
(let* ((overlay (widget-get button :button-overlay)) |
875 |
(face (overlay-get overlay 'face)) |
(face (overlay-get overlay 'face)) |
876 |
(mouse-face (overlay-get overlay 'mouse-face))) |
(mouse-face (overlay-get overlay 'mouse-face))) |
911 |
(overlay-put overlay 'face face) |
(overlay-put overlay 'face face) |
912 |
(overlay-put overlay 'mouse-face mouse-face)))) |
(overlay-put overlay 'mouse-face mouse-face)))) |
913 |
|
|
914 |
(unless (pos-visible-in-window-p (widget-event-point event)) |
(unless (pos-visible-in-window-p (widget-event-point event)) |
915 |
(mouse-set-point event) |
(mouse-set-point event) |
916 |
(beginning-of-line) |
(beginning-of-line) |
917 |
(recenter))) |
(recenter)) |
918 |
|
) |
919 |
|
|
920 |
(let ((up t) command) |
(let ((up t) command) |
921 |
;; Mouse click not on a widget button. Find the global |
;; Mouse click not on a widget button. Find the global |