Re: catch problems

From: Erick Gallesio <>
Date: Wed, 23 Oct 1996 11:43:45 +0200

> "Albert L. Ting" writes
> I've been trying to create a simple balloon help mechanism where by if the
> mouse enters and stays in a region, a toplevel window pops up with some
> help text. For the most part, it works. However, there's some 'race'
> condition such that a "(catch (destroy toplevel-ballon-widget))" will still
> cause a "bad pathname" error.

I'm afraid I cannot answer here, but it seems quite similar to the problem

BTW, I have written a small function to use balloon help which use menu
rather than toplevels (and I don't hav to setroy a tolevel, just to unpost
a menu ...)
Here it is. I will probably add this code for next release.

(define add-balloon-info
  (let* ((handler #f)
         (help (make <Menu> :background "yellow" :tear-off #f :relief "flat"
                        :font "fixed"))
         (display (lambda (W txt)
                    (after 'cancel handler)
                    (set! handler
                          (after 800
                                 (lambda ()
                                   ;; Change the help text
                                   (menu-entry-configure help 0 :label txt)
                                   ;; place the balloon just outside the widget
                                   (let ((height (winfo 'height W))
                                         (pos-y (winfo 'rooty W)))
                                     (menu-post help (winfo 'pointerx W)
                                                     (+ pos-y height 2))))))))
         (delete (lambda ()
                    (catch (menu-unpost help))
                    (after 'cancel handler))))
    ;; Initalize the menu widget
    (menu-add help 'command :label "")

    ;; Return a closure which associate new bindings to a "ballooned" widget
    (lambda (w txt)
      (bind w "<Enter>" (lambda () (display w txt)))
      (bind w "<Leave>" (lambda () (delete))))))

And an example of usage of this function

(define b1 (make <Button> :text "B1"))
(define b2 (make <Button> :text "B2"))
(pack b1 b2 :side "left")

(add-balloon-info b1 "Bouton 1")
(add-balloon-info b2 "Bouton 2")

                -- Erick
Received on Wed Oct 23 1996 - 11:44:48 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST