[plt-scheme] Misunderstanding MrEd window focus and event handling

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Mon Apr 17 17:23:28 EDT 2006

Hi everyone,

I'm playing around with MrEd, and I'm misunderstanding something (as 
usual).  Here's a small example:

(module test-ui mzscheme
   (require (lib "mred.ss" "mred")
            (lib "class.ss"))
   (define f1 (new frame% [label "hello"]))
   (define m1 (new message% [label "world"] [parent f1]))

   (define f2 (new frame% [label "goodbye"]))
   (define m2 (new message% [label "gaia"] [parent f2]))

   (send f1 show #t)
   (send f2 show #t)

   (thread (lambda ()
             (let loop ([i 0])
               (printf "loop ~a~n" i)
               (sleep 1)
               (send f1 focus)
               (send m1 set-label (format "world ~a" i))
               (sleep 1)
               (send f2 focus)
               (send m2 set-label (format "gaia ~a" i))
               (loop (add1 i))))))

After running 'mred -u test-ui.ss' I was hoping to see window focus bounce 
between the two windows, but at the moment, I'm only seeing my f2 frame 
with focus, and the contents of the frames are also not updating.  I 
suspect my confusion is really about how MrEd handles its event loop.

I assumed that my set-labels and focus commands are being queued up in the 
eventspace, and that MrEd would work through those as it finds idle time. 
I know I'm missing something, and I'll read through the MrEd documentation 
more deeply.  But any help would be appreciated too.  *grin* Thanks!

Posted on the users mailing list.