Modal dialog that disables its parent menubar in Racket / GUI?

  • Using the racket library rake, I believe I cannot have a real modal dialog that, when shown, cannot activate the parent window.
  • Although the dialog blocks the parent event space, you can click the menu bar in the parent window, and thus the same dialog can be shown over and over again. Below is the code:

#lang racket/gui

(define frame (new frame%
                   [label "test"]
                   [width 200]
                   [height 200]))

(define mb (new menu-bar% [parent frame]))

(let ([m (new menu% 
              [parent mb]
              [label "&About"])])
  (new menu-item%
       [parent m]
       [label "&About"]
       [callback (lambda (b e) (message-box "About" "This is a test." frame))])
  )


(send frame show #t)

      

(ps a dialog may appear in the message box - the same as (new dialog% [parent frame])

)

So if we ignore the first question, can we show a modal dialog that disables the parent menu bar?

Also, is it really impossible to create a real modal dialog in racket / gui?

(I am working on Win7)

+3


source to share


3 answers


Follow-up: This was a bug and will be fixed.

Literature:



+2


source


Instead of using frame%

, I think you want to use the class dialog%

. I'm not sure if you can make a modal dialog that has a menu bar.



Oh, also keep in mind which dialog%

is only modal to your event space. So if you run a snippet of code from DrRacket that creates a dialog, then DrRacket itself will be available.

+2


source


This seems a bit hackish, but you can do it yourself with [callback (lambda (b e) (send mb enable #f) (message-box "About" "This is a test.") (send mb enable #t))]

Or perhaps use dynamic-wind

if continuations are involved which in your example they are not.

0


source







All Articles