Does this code help?
#lang racket/gui
(require framework)
(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 chain-to-keymap (keymap:get-global) #t)
(send f show #t)
On Sat, Apr 9, 2016 at 6:04 AM, mazert <[email protected]> wrote:
> Le 08/04/2016 20:27, Matthew Flatt a écrit :
>> 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:
>
> Hmm, your solution do not select a word but the entire text-field% content
> (equivalent of triple left click).
>
> I found something called "select-click-word" on the framework
> http://docs.racket-lang.org/framework/Keymap.html#%28def._%28%28lib._framework%2Fmain..rkt%29._keymap~3asetup-global%29%29
> but I can't access it directly without setting all keymaps of
> keymap:get-global.
>
> By looking the procedure on the source code of this framework, I found some
> interesting methods of text% who can be useful (find-wordbreaks,
> set-position..), but after some experiments i cant make it working.. :p :
> https://searchcode.com/codesearch/view/7268171/
>
>
>> 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.
>
> I did it by creating a new class heriting of text-field%, and I work
> directly on the edit%, but you are right and it is surely a proper way to do
> that.
>
> ; Keybindings for basic edition
> (define textField%
> (class text-field%
> (super-new)
> (define keymap (keymap:get-editor))
> (send (send this get-editor) set-keymap keymap)))
>
>
>
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.