Le 10/06/2015 12:08, Laurent a écrit :
Maybe you can derive a class my-list-box% from list-box% and catch the
`on-subwindow-char` event:
http://docs.racket-lang.org/gui/window___.html#%28meth._%28%28%28lib._mred%2Fmain..rkt%29._window~3c~25~3e%29._on-subwindow-char%29%29

and then manually trigger the same callback as the button (it's better
to create a separate function instead of directly calling the button's
callback).

Hello, sorry if my answer took time.

Indeed, after trying your solution, it works very well. I coded something with a new "on-del" property that take a function.

Thanks you for the good idea !

-------------------------------------------------------------------------

#lang racket
(require racket/gui)

(define my-list-box%
  (class list-box%
    (init-field on-del)
    (define/override (on-subwindow-char r ke)
      (let ([keycode (send ke get-key-code)]
            [sel (send this get-selection)])
        (when (and (equal? keycode #\rubout) (integer? sel))
          (on-del sel)))
      (super on-subwindow-char r ke))
    (super-new)))

(define FRAME (new frame% (label "toto")))
(define list-box (new my-list-box%
                      (label "List Box")
                      (parent (new horizontal-panel%
                                   (parent FRAME)
                                   (style (list 'border))))
                      (choices (list "Item 0"
                                     "Item 1"
                                     "Item 2"))
                      (style (list 'single
                                   'column-headers))
                      (columns (list "First Column"))
                      (on-del (lambda (x)
                                (display x)
                                (send list-box delete x)))))


(send FRAME show #t)


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to