diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2007-10-31 19:54:41 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2007-10-31 19:54:41 +0000 |
commit | 9a39d26529bddefddc276b45becfbce79bb35bf1 (patch) | |
tree | 305e0baf1d12acfe34bf156193e4ba8f256ea9b4 /cursor.c | |
parent | 300914553d7e70cc7265db078e5730e159b9b2da (diff) |
added bang method and made button and wheel events always be reported, not only when polling
svn path=/trunk/externals/hcs/; revision=8919
Diffstat (limited to 'cursor.c')
-rw-r--r-- | cursor.c | 36 |
1 files changed, 23 insertions, 13 deletions
@@ -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 <ButtonPress> {+pd [concat %s button %%b 1 \\;]}\n", - x->receive_symbol->s_name); - sys_vgui("bind all <ButtonRelease> {+pd [concat %s button %%b 0 \\;]}\n", - x->receive_symbol->s_name); sys_vgui("bind all <Motion> {+pd [concat %s motion %%x %%y \\;]}\n", x->receive_symbol->s_name); - sys_vgui("bind all <MouseWheel> {+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 <ButtonPress> {+pd [concat %s button %%b 1 \\;]}\n", + x->receive_symbol->s_name); + sys_vgui("bind all <ButtonRelease> {+pd [concat %s button %%b 0 \\;]}\n", + x->receive_symbol->s_name); + sys_vgui("bind all <MouseWheel> {+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); } |