78 |
(put 'default-button 'mouse-face 'highlight) |
(put 'default-button 'mouse-face 'highlight) |
79 |
(put 'default-button 'keymap button-map) |
(put 'default-button 'keymap button-map) |
80 |
(put 'default-button 'type 'button) |
(put 'default-button 'type 'button) |
81 |
|
;; action may be either a function to call, or a marker to go to |
82 |
(put 'default-button 'action 'ignore) |
(put 'default-button 'action 'ignore) |
83 |
(put 'default-button 'help-echo "mouse-2, RET: Push this button") |
(put 'default-button 'help-echo "mouse-2, RET: Push this button") |
84 |
;; Make overlay buttons go away if their underlying text is deleted. |
;; Make overlay buttons go away if their underlying text is deleted. |
218 |
If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
219 |
instead of its normal action; if the button has no mouse-action, |
instead of its normal action; if the button has no mouse-action, |
220 |
the normal action is used instead." |
the normal action is used instead." |
221 |
(funcall (or (and use-mouse-action (button-get button 'mouse-action)) |
(let ((action (or (and use-mouse-action (button-get button 'mouse-action)) |
222 |
(button-get button 'action)) |
(button-get button 'action)))) |
223 |
button)) |
(if (markerp action) |
224 |
|
(save-selected-window |
225 |
|
(select-window (display-buffer (marker-buffer action))) |
226 |
|
(goto-char action) |
227 |
|
(recenter 0)) |
228 |
|
(funcall action button)))) |
229 |
|
|
230 |
(defun button-label (button) |
(defun button-label (button) |
231 |
"Return BUTTON's text label." |
"Return BUTTON's text label." |
379 |
|
|
380 |
(defun push-button (&optional pos use-mouse-action) |
(defun push-button (&optional pos use-mouse-action) |
381 |
"Perform the action specified by a button at location POS. |
"Perform the action specified by a button at location POS. |
382 |
POS may be either a buffer position or a mouse-event. |
POS may be either a buffer position or a mouse-event. If |
383 |
If USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
USE-MOUSE-ACTION is non-nil, invoke the button's mouse-action |
384 |
instead of its normal action; if the button has no mouse-action, |
instead of its normal action; if the button has no mouse-action, |
385 |
the normal action is used instead. |
the normal action is used instead. The action may be either a |
386 |
|
function to call or a marker to display. |
387 |
POS defaults to point, except when `push-button' is invoked |
POS defaults to point, except when `push-button' is invoked |
388 |
interactively as the result of a mouse-event, in which case, the |
interactively as the result of a mouse-event, in which case, the |
389 |
mouse event is used. |
mouse event is used. |