I have a simple program like:
#lang racket/gui
(define current-width (make-parameter #f))
(define (run-fullscreen proc)
(define window
(new
(class frame%
(super-new)
(define/override (on-size new-width new-height)
(current-width new-width)
(writeln (list new-width new-height))))
(label "Test")))
(send window fullscreen #t)
(send window show #t)
(define main-thread (thread proc))
(thread-wait main-thread)
(send window show #f))
(displayln (current-width))
(run-fullscreen
(thunk
(displayln (current-width))
(sleep 1)
(displayln (current-width))
(displayln "In run-fullscreen.")))
Running it produces:
#f
#f
#f
In run-fullscreen.
(1 1)
(2160 1350)
Yes, without parameterized eventspace, the GUI thread does not have a chance to update the parameter, but with a small change, it (in theory) should do the trick:
#lang racket/gui
(define current-width (make-parameter #f))
(define (run-fullscreen proc)
(parameterize ((current-eventspace (make-eventspace)))
(define window
(new
(class frame%
(super-new)
(define/override (on-size new-width new-height)
(current-width new-width)
(writeln (list new-width new-height))))
(label "Test")))
(send window fullscreen #t)
(send window show #t)
(define main-thread (thread proc))
(thread-wait main-thread)
(send window show #f)))
(displayln (current-width))
(run-fullscreen
(thunk
(displayln (current-width))
(sleep 1)
(displayln (current-width))
(displayln "In run-fullscreen.")))
But it doesn't:
#f
#f
(1 1)
(2160 1350)
#f
In run-fullscreen.
Should I abandon parameters altogether in this case or do I overlook something basic?
The code shown is just a minimal example. In the real application the frame% also contains one and only child canvas% instance.
I want to be able to set/update some values in the GUI initialization, some in some GUI callbacks (on-size of frame%, on-char and on-event of canvas%) and the proc being run (mainly the canvas - immediate and only frame% child in the real application).