[plt-scheme] editor-canvas% and popup-menu%

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Thu Apr 13 05:25:24 EDT 2006

Hi,

I have three problems, but maybe I have missed something in
the documentation.

1.
editor-canvas%
For this widget in the style I can specify 'combo', and it
draws out the 
arrow at the end of the widget. However I cannot find anyway
to use
this feature. I cannot find out that the user has clicked on
the arrow 
as there is no callback for it. I cannot determine that the
mouse is in
the area of the arrow and the user clicked as the size of
the arrow
is a private constant for MrEd. (I could copy out from the
const.ss file
the side-combo-width value, but I assume that is not the way
forward.)
So in my view there is a little inconsistency:
- Either remove this feature being public, which I do not
like or
- it should be more accessible, for example with the constant or
  with another callback, or with an event type 

2. popup-menu%
Below you can find a little code, which I think, was
published in this
list. My problem is with the set-min-width method for the
popup-menu%
widget. It simply does not work. No matter what value I
specify it only
creates widgets with the size of the text.

3.
This is a bit related to the popup-menu. How can I create a
menu item
which has a non-default color as a background? I cannot find
which
class defines the style and which one I have to redefine.

Thanks for any help,

Peter Ivanyi


(define f (new frame%
               [label "Example"]
               [width 200]
               [height 200]))
(define e (new text%))
(new editor-canvas%
     [parent f]
     [editor e])

;; In the editor keymap, map right-button click to
;;  popup a menu
(let ([km (send e get-keymap)])
  ;; Add a popup-menu function to the keymap:
  (send km add-function "do-popup"
        (lambda (e evt)
          ;; Create the menu....
          (let ([menu (new popup-menu%)])
            (new menu-item% 
                 [parent menu]
                 [label "Example"]
                 [callback (lambda (i evt)
                             (printf "Got it~n"))])
            
            ;; Convert the event coordinates to editr
coordinates
            (let-values ([(x y) (send e
dc-location-to-editor-location
                                      (send evt get-x) (send
evt get-y))])
              ;;;; PROBLEM
              (send menu set-min-width 200)
              ;; Ask the editor's display to show the pop-up
menu
              (send (send e get-admin) popup-menu menu x y))
            
          )
          ))
  ;; Map rightbutton to the popup-menu function
  (send km map-function "rightbutton" "do-popup"))

(send f show #t)


_______________________________________________________________________
Rövid és hosszú távú befektetések interneten keresztül! Számlavezetési díj már 125 Ft-tól!
www.klikkbank.hu




Posted on the users mailing list.