Mercurial > hg > xemacs-beta
diff lisp/gui.el @ 454:d7a9135ec789 r21-2-42
Import from CVS: tag r21-2-42
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:40:54 +0200 |
parents | 3ecd8885ac67 |
children | 5be46355cc42 |
line wrap: on
line diff
--- a/lisp/gui.el Mon Aug 13 11:40:23 2007 +0200 +++ b/lisp/gui.el Mon Aug 13 11:40:54 2007 +0200 @@ -94,14 +94,25 @@ (set-face-foreground 'gui-button-face '(((x color) . "black") ((mswindows color) . "black"))))) + +(defun gui-button-action (instance action user-data) + (let ((domain (image-instance-domain instance))) + (with-current-buffer (if (windowp domain) + (window-buffer domain) nil) + (funcall action user-data)))) + (defun make-gui-button (string &optional action user-data) "Make a GUI button whose label is STRING and whose action is ACTION. If the button is inserted in a buffer and then clicked on, and ACTION -is non-nil, ACTION will be called with one argument, USER-DATA." +is non-nil, ACTION will be called with one argument, USER-DATA. +When ACTION is called, the buffer containing the button is made current." (vector 'button :descriptor string :face 'gui-button-face - :callback `(funcall (quote ,action) (quote ,user-data)))) + :callback-ex `(lambda (image-instance event) + (gui-button-action image-instance + (quote ,action) + (quote ,user-data))))) (defun insert-gui-button (button &optional pos buffer) "Insert GUI button BUTTON at POS in BUFFER."