[PD-dev] glist_grab not grabbing arrows

federico mescalinum at gmail.com
Wed Sep 5 22:53:19 CEST 2007


> > I searched thru the externals... didn't found one using arrow keys.
> > anyone can give an example of capturing arrow keys?
>
> There are internals for that: [key], [keyup] and [keyname], you can
> look at their code in x_gui.c

ok, I understand pd_bind().

but there are 2 drawbacks in that approach:

1) binding to the class itself, it implies dedicating the list
selector for receiving such keystrokes (well, it could be solved by
using a proxy class which calls a method of the real class.... kinda
hackery)

2) I want to receive those keystrokes only when the class gui is
focused and in edit mode (like floatatom does, and in general like the
glist_grab behavior) - no solution for that


also: would be nice to know if there exists some method to know when
the gui has focus and when it loses focus, or just a boolean flag to
ask for...


also(2): I found this, reading g_editor.c line ~1520

        else if (x->gl_editor->e_textedfor && (keynum
            || !strcmp(gotkeysym->s_name, "Up")
            || !strcmp(gotkeysym->s_name, "Down")
            || !strcmp(gotkeysym->s_name, "Left")
            || !strcmp(gotkeysym->s_name, "Right")))
        {

the elseif condition doesn't make much sense!
proof: boolean operator OR has the associative property, so I can
rewrite the condition as:

        (x->gl_editor->e_textedfor && (keynum ||
      ( !UP || !DN || !LEFT || !RIGHT )
         ))

(I adjusted names a little bit just to be more clear)
now using the De Morgan's law[1], the above is equivalent to:

        (x->gl_editor->e_textedfor && (keynum ||
      !( UP && DN && LEFT && RIGHT )
         ))

so it's like asking: gotkeysym->s_name MUST NOT BE EQUAL to 4 values
in the same time.
it evaluates always to 1?
then the above simplifies as:

        (x->gl_editor->e_textedfor && keynum)


forgive me if I am not seeing something important here, just I'm
looking for other answers (see much above), I found this thing and
reported here, hoping doing something useful.

just I was reading g_editor.c to understand how to grab arrows keys,
but now I'm lost :(

-- 
Federico

[1]: http://en.wikipedia.org/wiki/De_Morgan's_laws




More information about the Pd-dev mailing list