7

NOTE: Racket GUI 避免重複開啟視窗

 2 years ago
source link: https://dannypsnl.github.io/blog/2021/03/06/cs/racket-gui-avoid-retrigger-frame/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

NOTE: Racket GUI 避免重複開啟視窗

首先用 define/augmenton-close 附加一些額外的控制程式碼

(define open? #f)

(define custom-frame%
  (class frame%
    (super-new [label "test"]
               [width 300] [height 300])

    (define/augment (on-close)
      (set! open? #f))

    (set! open? #t)))

接著設計一個只有當 flag 被設定好時才會開啟視窗(frame)的函數

(define (show-it!)
  (unless open?
    (define f (new custom-frame%))
    (send f show #t)
    (send f center)))

最後就可以得到重複觸發也不會重複開啟的視窗啦!

(show-it!)
(show-it!)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK