diff --git a/collects/mred/private/messagebox.rkt b/collects/mred/private/messagebox.rkt index b598fbccd2..38733d0ffb 100644 --- a/collects/mred/private/messagebox.rkt +++ b/collects/mred/private/messagebox.rkt @@ -41,6 +41,27 @@ l)) style) + (let ([go (lambda () + (create-message-box/custom + who title message + button1 button2 button3 + parent style close-result + check? two-results? check-message))]) + (if (eq? (current-thread) (wx:eventspace-handler-thread (wx:current-eventspace))) + ;; In the right thread: + (go) + ;; Not in the right thread: + (let ([ch (make-channel)]) + (wx:queue-callback + (lambda () + (channel-put ch (call-with-values go list)))) + (apply values (channel-get ch))))))) + + (define create-message-box/custom + (lambda (who title message + button1 button2 button3 + parent style close-result + check? two-results? check-message) (let* ([strings (regexp-split #rx"\n" message)] [single? (and (< (length strings) 10) (andmap (lambda (s) (< (string-length s) 60)) strings))] @@ -212,7 +233,7 @@ #f #f #f))) (define do-message-box - (opt-lambda (who title message parent style check? check-message) + (lambda (who title message parent style check? check-message) (check-label-string who title) (check-string/false who message) (when check? diff --git a/collects/scribblings/gui/dialog-funcs.scrbl b/collects/scribblings/gui/dialog-funcs.scrbl index 1644637a3d..47b2e262f4 100644 --- a/collects/scribblings/gui/dialog-funcs.scrbl +++ b/collects/scribblings/gui/dialog-funcs.scrbl @@ -180,10 +180,9 @@ See also @scheme[path-dialog%]. [parent (or/c (is-a?/c frame%) (is-a?/c dialog%) false/c) #f] [style (listof (one-of/c 'ok 'ok-cancel 'yes-no 'caution 'stop)) '(ok)]) (one-of/c 'ok 'cancel 'yes 'no)]{ + See also @scheme[message-box/custom]. - - Displays a message to the user in a (modal) dialog, using @scheme[parent] as the parent window if it is specified. The dialog's title is @scheme[title]. The @scheme[message] string can be arbitrarily @@ -220,12 +219,11 @@ In addition, @scheme[style] can contain @scheme['caution] to make the The class that implements the dialog provides a @scheme[get-message] method that takes no arguments and returns the text of the message as a string. (The dialog is accessible through the -@scheme[get-top-level-windows] function.) + @scheme[get-top-level-windows] function.) - - - -} +The @racket[message-box] function can be called int a thread other + than the current eventspace's handler thread, in which case the + current thread blocks while the dialog runs on the handler thread.} @defproc[(message-box/custom [title label-string?] [message string] @@ -307,9 +305,9 @@ The class that implements the dialog provides a @scheme[get-message] a string. (The dialog is accessible through the @scheme[get-top-level-windows] function.) - - -} +The @racket[message-box/custom] function can be called int a thread + other than the current eventspace's handler thread, in which case the + current thread blocks while the dialog runs on the handler thread.} @defproc[(message+check-box [title label-string?] [message string]