Re: catch problems

From: Erick Gallesio <eg_at_kaolin.unice.fr>
Date: Sat, 26 Oct 1996 12:24:16 +0200

> "Albert L. Ting" writes
>
> Thanks for the function. But I have one question, can it support
> multi-line balloon help? Or is this a limitation of menu buttons?

As written, no. Menu button are mono-line only. But Tk allow to make
subwindows in a menu. So It is possible to embedd a label (labels are multi
lines) in a menu. The code previously senthas been adapted for this:
(define add-balloon-info
  (let* ((handler #f)
         (helpm (make <Menu>))
         (help (make <Label> :parent helpm :background "yellow"
                                  :relief "flat"))
         (display (lambda (W txt)
                    (after 'cancel handler)
                    (set! handler
                          (after 800
                                 (lambda ()
                                   ;; Change the help text
                                   (slot-set! help 'text txt)
                                   ;; place the balloon just outside the widget
                                   (let ((height (winfo 'height W))
                                         (pos-y (winfo 'rooty W)))
                                     (menu-post helpm (winfo 'pointerx W)
                                                      (+ pos-y height 2))))))))
         (delete (lambda ()
                    (catch (menu-unpost helpm))
                    (after 'cancel handler))))
    
    ;; pack the label
    (pack help :fill "both" :expand #t)

    ;; 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))))))



                -- Erick
Received on Sat Oct 26 1996 - 15:10:07 CEST

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