From 85883eef31dee5aedf23606aa43490189d568d08 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Fri, 18 Sep 2020 10:43:42 -0400 Subject: [PATCH] Disables passing of key presses globally when an x->gl_editor->e_keyfn is not null * This means an object has requested exclusive focus --- pd/src/g_editor.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 50f8d035c..38d6ddf15 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5476,34 +5476,39 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) t_atom at[2]; // now broadcast key press to key et al. objects - if (!autorepeat) + // ico@vt.edu 20200918: only do so if we do not have an object + // that has grabbed the keyboard, such as gatom or iemgui numbox + if (!x->gl_editor->e_keyfn) { - if (keynumsym->s_thing && down) - pd_float(keynumsym->s_thing, (t_float)keynum); - if (keyupsym->s_thing && !down) - pd_float(keyupsym->s_thing, (t_float)keynum); - if (keynamesym->s_thing) + if (!autorepeat) + { + if (keynumsym->s_thing && down) + pd_float(keynumsym->s_thing, (t_float)keynum); + if (keyupsym->s_thing && !down) + pd_float(keyupsym->s_thing, (t_float)keynum); + if (keynamesym->s_thing) + { + at[0] = av[0]; + SETFLOAT(at, down); + SETSYMBOL(at+1, gotkeysym); + pd_list(keynamesym->s_thing, 0, 2, at); + } + } + + // now do the same for autorepeat-enabled objects (key et al. alternative behavior) + if (keynumsym_a->s_thing && down) + pd_float(keynumsym_a->s_thing, (t_float)keynum); + if (keyupsym_a->s_thing && !down) + pd_float(keyupsym_a->s_thing, (t_float)keynum); + if (keynamesym_a->s_thing) { at[0] = av[0]; SETFLOAT(at, down); SETSYMBOL(at+1, gotkeysym); - pd_list(keynamesym->s_thing, 0, 2, at); + pd_list(keynamesym_a->s_thing, 0, 2, at); } } - // now do the same for autorepeat-enabled objects (key et al. alternative behavior) - if (keynumsym_a->s_thing && down) - pd_float(keynumsym_a->s_thing, (t_float)keynum); - if (keyupsym_a->s_thing && !down) - pd_float(keyupsym_a->s_thing, (t_float)keynum); - if (keynamesym_a->s_thing) - { - at[0] = av[0]; - SETFLOAT(at, down); - SETSYMBOL(at+1, gotkeysym); - pd_list(keynamesym_a->s_thing, 0, 2, at); - } - if (!x || !x->gl_editor) return; if (x && down) -- GitLab