Binding mouse event to a canvas 
Author Message
 Binding mouse event to a canvas

 I am trying to bind some actions to some mouse events.  It is probably
 simple, but none of the docs or examples show clearly how it is done.
 At least what I've tried based on docs and examples doesn't work.  Here
 is my code fragment:

        $c->bind ($c, '<1>' => sub { draw_object ($t) });

        where $c is my canvas widget, and $t holds the kind of object
        (oval, polygon, ...) that I want do draw.

I'm not an experienced tcl/tk programmer but it seems
like I should be able to put my mouse over the canvas, press mouse-1.
What am missing?  I've also tried binding the event to 'Tk::Canvas',
'.', and '.canvas'.  Should I be associating a tag with the canvas widget?

Mike Lockhart



Sun, 20 Sep 1998 03:00:00 GMT  
 Binding mouse event to a canvas

Quote:

> I am trying to bind some actions to some mouse events.  It is probably
> simple, but none of the docs or examples show clearly how it is done.
> At least what I've tried based on docs and examples doesn't work.  Here
> is my code fragment:

>    $c->bind ($c, '<1>' => sub { draw_object ($t) });

>    where $c is my canvas widget, and $t holds the kind of object
>    (oval, polygon, ...) that I want do draw.

$c->Tk::bind('<1>' => sub { draw_object ($t) });

binds the action to the entire canvas....



Mon, 21 Sep 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. help binding mouse events to canvas

2. detecting mouse events with canvas widget

3. Problem with binding events on TkPerl canvas

4. binding an event to an item in a canvas widget

5. Problem with mouse event to Tree

6. Mouse events : release button

7. Newbie: Mouse events

8. Responding to mouse/keyboard events?

9. Mouse click location on a scrolled canvas

10. problems tracking a mouse drag over canvas items,

11. Mouse pointer position on a canvas?

12. Followup: Moving Mouse on Canvas

 

 
Powered by phpBB® Forum Software