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.

Reply via email to