Mercurial > hg > xemacs-beta
comparison lisp/dialog.el @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 7347b34c275b |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
28 | 28 |
29 ;; This file is dumped with XEmacs (when dialog boxes are compiled in). | 29 ;; This file is dumped with XEmacs (when dialog boxes are compiled in). |
30 | 30 |
31 ;;; Code: | 31 ;;; Code: |
32 (defun yes-or-no-p-dialog-box (prompt) | 32 (defun yes-or-no-p-dialog-box (prompt) |
33 "Ask user a yes-or-no question with a popup dialog box. | 33 "Ask user a \"y or n\" question with a popup dialog box. |
34 Return t if the answer is \"yes\". | 34 Returns t if answer is \"yes\". |
35 Takes one argument, which is the string to display to ask the question." | 35 Takes one argument, which is the string to display to ask the question." |
36 (save-selected-frame | 36 (let ((echo-keystrokes 0) |
37 (let ((echo-keystrokes 0) | 37 event) |
38 event) | 38 (popup-dialog-box |
39 (popup-dialog-box | 39 ;; "Non-violent language please!" says Robin. |
40 (cons prompt '(["Yes" yes t] ["No" no t] nil ["Cancel" abort t]))) | 40 (cons prompt '(["Yes" yes t] ["No" no t] nil ["Cancel" abort t]))) |
41 (catch 'ynp-done | 41 ; (cons prompt '(["Yes" yes t] ["No" no t] nil ["Abort" abort t]))) |
42 (while t | 42 (catch 'ynp-done |
43 (setq event (next-command-event event)) | 43 (while t |
44 (cond ((and (misc-user-event-p event) (eq (event-object event) 'yes)) | 44 (setq event (next-command-event event)) |
45 (throw 'ynp-done t)) | 45 (cond ((and (misc-user-event-p event) (eq (event-object event) 'yes)) |
46 ((and (misc-user-event-p event) (eq (event-object event) 'no)) | 46 (throw 'ynp-done t)) |
47 (throw 'ynp-done nil)) | 47 ((and (misc-user-event-p event) (eq (event-object event) 'no)) |
48 ((and (misc-user-event-p event) | 48 (throw 'ynp-done nil)) |
49 (or (eq (event-object event) 'abort) | 49 ((and (misc-user-event-p event) |
50 (eq (event-object event) 'menu-no-selection-hook))) | 50 (or (eq (event-object event) 'abort) |
51 (signal 'quit nil)) | 51 (eq (event-object event) 'menu-no-selection-hook))) |
52 ((button-release-event-p event);; don't beep twice | 52 (signal 'quit nil)) |
53 nil) | 53 ((button-release-event-p event) ;; don't beep twice |
54 (t | 54 nil) |
55 (beep) | 55 (t |
56 (message "please answer the dialog box")))))))) | 56 (beep) |
57 (message "please answer the dialog box"))))))) | |
57 | 58 |
58 (defun yes-or-no-p-maybe-dialog-box (prompt) | 59 (defun yes-or-no-p-maybe-dialog-box (prompt) |
59 "Ask user a yes-or-no question. Return t if answer is yes. | 60 "Ask user a yes-or-no question. Return t if answer is yes. |
60 The question is asked with a dialog box or the minibuffer, as appropriate. | 61 The question is asked with a dialog box or the minibuffer, as appropriate. |
61 Takes one argument, which is the string to display to ask the question. | 62 Takes one argument, which is the string to display to ask the question. |