On Sep 5, 2007, at 4:53 PM, federico wrote:
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:
- 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)
- 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
Check out:
[cyclone/active] gives you window focus info.
[key] , [keyup], [keyname] gives you all key strokes
This gives you some editmode info
[loadbang] | [capture 1( | [toxy/tot .] | [route editmode] |
.hc
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
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
------------------------------------------------------------------------ ----
kill your television