Created
May 8, 2018 00:30
-
-
Save alex-hhh/20b3f1000813677330bbd2b85c57d319 to your computer and use it in GitHub Desktop.
Double dialog problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/gui) | |
;; Sequence of events to illustrate the problem: | |
;; | |
;; 1. Open Dialog 1 | |
;; | |
;; 2. Open Dialog 2 | |
;; | |
;; 3. Close Dialog 2 -- notice that dialog 1 now has focus | |
;; | |
;; 4. Close Dialog 1 -- notice that the main window is now at the bottom of | |
;; the window stack and does not have focus | |
;; | |
;; This sequence of events works correctly: | |
;; | |
;; 1. Open Dialog 1 | |
;; | |
;; 2. Close Dialog 1 -- notice that the main window has focus | |
(define toplevel (new frame% | |
[label "Hello World"] | |
[width 800] | |
[height 600])) | |
(define dialog-1 (new dialog% | |
[parent toplevel] | |
[label "Dialog 1"] | |
[width 400] | |
[height 300])) | |
(define dialog-2 (new dialog% | |
[parent dialog-1] | |
[label "Dialog 2"] | |
[width 200] | |
[height 150])) | |
(define (on-open-dialog1 button event) | |
(send dialog-1 show #t)) | |
(define (on-close-dialog1 button event) | |
(send dialog-1 show #f)) | |
(define (on-open-dialog2 button event) | |
(send dialog-2 show #t)) | |
(define (on-close-dialog2 button event) | |
(send dialog-2 show #f)) | |
(define b1 (new button% | |
[parent toplevel] | |
[label "Open Dialog 1..."] | |
[callback on-open-dialog1])) | |
(define b2 (new button% | |
[parent dialog-1] | |
[label "Open Dialog 2..."] | |
[callback on-open-dialog2])) | |
(define b3 (new button% | |
[parent dialog-1] | |
[label "Close Dialog 1"] | |
[callback on-close-dialog1])) | |
(define b4 (new button% | |
[parent dialog-2] | |
[label "Close Dialog 2"] | |
[callback on-close-dialog2])) | |
(send toplevel show #t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment