At Fri, 8 Apr 2016 18:50:09 +0200, mazert wrote: > I try to find an easy way to add the general mouse selection system > (double click on a word will select it for example) on a text-field gui > component.
In the case of double-click to select a word, you could implement it via the keymap in a text-field's editor: ---------------------------------------- #lang racket/gui (define f (new frame% [label "Select"] [width 300])) (define t (new text-field% [parent f] [label #f])) (define k (send (send t get-editor) get-keymap)) (send k add-function "select-word" (lambda (t e) ;; TODO: actually select a word using the ;; methods of `text%`: (send t select-all))) (send k map-function "leftbuttondouble" "select-word") (send f show #t) ---------------------------------------- For more complex behavior, you may need to use an `editor-canvas%` plus `text%`. A `text-field%` widget combines an `editor-canvas%` with a `text%` for you, but it doesn't give you an opportunity to subclass `text%`, which may be necessary for some tasks. -- 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.