Hi Georg,

I'm not terribly familiar with ui.gadgets, but I can at least help you figure 
out what's going on here.

The word `handle-gesture` is generic 
(http://docs.factorcode.org/content/word-handle-gesture,ui.gestures.html), so 
it does different things depending on its argument classes.

You can tell whether an `editor` object will handle a given gesture with 
`handles-gesture?` 
(http://docs.factorcode.org/content/word-handles-gesture__que__,ui.gestures.html)

`T{ key-down { sym "HOME" } } <editor> handles-gesture?` is `t` because 
`editor` handles `HOME`, but the same code with `T{ key-down { sym "a" } }` is 
`f`.

`editor` is a subclass of `line-gadget`, but `handle-gesture` defines a method 
on neither of these classes (see the above linked documentation).

This can be proven by writing `M\ line-gadget handle-gesture` and `M\ editor 
handle-gesture` both of which throw a `method-lookup-failed` error.

`handle-gesture` defines `M\ object handle-gesture` though, and that method 
definition is `[ nip ] [ get-gesture-handler ] 2bi dup [ ( gadget -- ) 
call-effect f ] [ 2drop t ] if`.

The important part of that is `get-gesture-handler`, the same word used by 
`handles-gesture?`.

`get-gesture-handler` looks at the `gestures` word property 
(http://docs.factorcode.org/content/word-word-prop,words.html) of the 
superclasses of the input `gadget` object. In the same way you can see what 
keys have gestures defined with `editor "gestures" word-prop .`, which is a 
long table like

`H{ { cut-action [ \ com-cut invoke-command ] } { redo-action [ \ com-redo 
invoke-command ] } { T{ key-down f f "BACKSPACE" } [ \ 
delete-previous-character invoke-command ] } ...`

It contains exclusively line-editing commands like`C+l` for select line but no 
input keys like `1`.

Some keys are defined by default, others are not -- I don't know why, but 
another person will probably reply to tell you why.

Hopefully it is somewhat enlightening!

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On July 2, 2018 8:00 AM, Georg Simon georg.si...@auge.de wrote:

> T{ key-down { sym "HOME" } } <editor> handle-gesture .
> 
> prints f as the gesture was handled. But
> ----------------------------------------
> 
> T{ key-down { sym "a" } } <editor> handle-gesture .
> 
> T{ key-down { sym "a" } }
> 
> <editor> [ handle-gesture ] keep editor-string . .
> 
> T{ key-down { sym "a" } }
> 
> "old" <editor> [ set-editor-string ] keep
> 
> [ handle-gesture ] keep editor-string . .
> -----------------------------------------
> 
> print t, "" and t, and "old" and t . Gesture was not handled.
> 
> Is there a way to send an arbitrary character to an editor ?
> 
> Check out the vibrant tech community on one of the world's most
> 
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> 
> Factor-talk mailing list
> 
> Factor-talk@lists.sourceforge.net
> 
> https://lists.sourceforge.net/lists/listinfo/factor-talk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to