[racket] How to automatically update the value of output widgets?

From: Marijn (hkBst at gentoo.org)
Date: Thu Feb 2 03:19:12 EST 2012

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01-02-12 18:06, Matthias Felleisen wrote:
> 
> If nobody responded: Philosophy 2/Idea A is what I'd go with if I
> had to get something done now, and Idea B would be something I'd
> pursue if I had time.

Indeed nobody else seems to have had time for an opinion on this. I
have since implemented Idea 2 since it was the only option that was
clear enough in my head. It goes like this:

#lang racket

(provide try-send try-send-all-children)

(define-syntax try-send
  (syntax-rules ()
    ((_ object msg failure-value)
     (with-handlers ((exn:fail:object? (lambda (e) failure-value)))
       (send object msg)))
    ((_ object msg) (try-send object msg #f)) ))

(define (for-each-transitive-child f parent)
  (define progeny (try-send parent get-children))
  (if progeny
      (for-each
       (lambda (child) (for-each-transitive-child f child))
       progeny)
      (f parent)))

(define-syntax-rule (try-send-all-children parent message)
  (for-each-transitive-child
   (lambda (c) (try-send c message))
   parent))

with this code and output widgets that implement an `update-value'
method I can try to send that message to each child of a tab. This
seems to works well so far in practice. I make input widgets call it
automatically when they change value and just discovered that I should
also call it on-super-window-show when I change tab, unless I change
my input widgets from calling this on their own tab to the root frame.

Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8qRwAACgkQp/VmCx0OL2z4TwCfYtpB1RgQskyzFkK5SX74S8cT
yuMAoLfMG+/nQwlckecY/yLwq5ZIU8oh
=/Xn4
-----END PGP SIGNATURE-----

Posted on the users mailing list.