From 9a39d26529bddefddc276b45becfbce79bb35bf1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 31 Oct 2007 19:54:41 +0000 Subject: added bang method and made button and wheel events always be reported, not only when polling svn path=/trunk/externals/hcs/; revision=8919 --- cursor.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'cursor.c') diff --git a/cursor.c b/cursor.c index 85e8537..cd323d6 100644 --- a/cursor.c +++ b/cursor.c @@ -22,21 +22,23 @@ typedef struct _cursor char *optionv[]; } t_cursor; + +static void cursor_bang(t_cursor *x) +{ + sys_vgui("pd [concat %s motion [winfo pointerx .] [winfo pointery .] \\;]\n", + x->receive_symbol->s_name); +} + static void cursor_float(t_cursor *x, t_float f) { if(f > 0) { - sys_vgui("bind all {+pd [concat %s button %%b 1 \\;]}\n", - x->receive_symbol->s_name); - sys_vgui("bind all {+pd [concat %s button %%b 0 \\;]}\n", - x->receive_symbol->s_name); sys_vgui("bind all {+pd [concat %s motion %%x %%y \\;]}\n", x->receive_symbol->s_name); - sys_vgui("bind all {+pd [concat %s wheel %%D \\;]}\n", - x->receive_symbol->s_name); } else { + /* TODO figure out how to turn off this binding */ } } @@ -94,6 +96,13 @@ static void *cursor_new(t_symbol *s, int argc, t_atom *argv) x->data_outlet = outlet_new(&x->x_obj, 0); x->status_outlet = outlet_new(&x->x_obj, 0); + sys_vgui("bind all {+pd [concat %s button %%b 1 \\;]}\n", + x->receive_symbol->s_name); + sys_vgui("bind all {+pd [concat %s button %%b 0 \\;]}\n", + x->receive_symbol->s_name); + sys_vgui("bind all {+pd [concat %s wheel %%D \\;]}\n", + x->receive_symbol->s_name); + return(x); } @@ -103,18 +112,19 @@ void cursor_setup(void) (t_newmethod)cursor_new, (t_method)cursor_free, sizeof(t_cursor), 0, 0); + class_addbang(cursor_class, (t_method)cursor_bang); class_addfloat(cursor_class, (t_method)cursor_float); + button_symbol = gensym("button"); + motion_symbol = gensym("motion"); + wheel_symbol = gensym("wheel"); + class_addmethod(cursor_class, (t_method)cursor_cursor, gensym("cursor"), A_DEFSYMBOL, 0); class_addmethod(cursor_class, (t_method)cursor_button_callback, - gensym("button"), A_DEFFLOAT, A_DEFFLOAT, 0); + button_symbol, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(cursor_class, (t_method)cursor_motion_callback, - gensym("motion"), A_DEFFLOAT, A_DEFFLOAT, 0); + motion_symbol, A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(cursor_class, (t_method)cursor_wheel_callback, - gensym("wheel"), A_DEFFLOAT, 0); - - button_symbol = gensym("button"); - motion_symbol = gensym("motion"); - wheel_symbol = gensym("wheel"); + wheel_symbol, A_DEFFLOAT, 0); } -- cgit v1.2.1