in reply to Re: Tk Mandelbrot Fractal
in thread Tk Mandelbrot Fractal

There are events listed in perldoc Tk::bind under the section Event types. You can get keyboard events, mouse clicks of a few varieties, and various things like Map and Unmap( which are basically iconify and deiconify).

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^3: Tk Mandelbrot Fractal
by BrowserUk (Patriarch) on Dec 07, 2006 at 21:35 UTC

    I know. But that is not my question.

    I'm specifically looking for what other information (besides x and y), are available (by default), from the object returned from $canvas->XEvent method in a mouse event callback. As in the OPs use:

    $e = $canvas -> XEvent; $canv_x = $e->x; $canv_y = $e->y;

    This has to be documented somewhere?

    Looking again at the Tk:bind docs at the section entitled "BINDING CALLBACKS AND SUBSTITUTIONS", it appears that you can choose froma wide variety and formats, what information gets passed to the callback by using the Ev() function(?) when forming the bind. But this appears to involve yet more callbacks and and dynamic evaluations, which slows things down horribly--as if it wasn't slow enough anyway.

    I was hoping to find that the default information supplied to a canvas mouse event callback included not just the window relative x/y, but also the canvas relative x/y. Performing the convesion isn't hard, but it involves yet more calls and just slows everything down again.

    I'm not sure why I (or anyone) bother persisting with using this stuff--it's just painful.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I've only see the mouse x, y event, and the keyboard event $e->K.
      #!/usr/bin/perl use warnings; use strict; use Tk; my $down = 0; my $mw = MainWindow->new; $mw->bind("<Key>", sub { &pressed } ); $mw->bind("<KeyRelease>", sub { &released } ); MainLoop; sub pressed{ my($widget) = @_; my $e = $widget->XEvent; # get reference to X11 event structure my $binding = 'Character = ' . $e->N . ', keysym = ' . $e->K . '.'; print "$binding\n"; print $e->K," pressed\n"; } sub released{ my($widget) = @_; my $e = $widget->XEvent; # get reference to X11 event structure my $binding = 'Character = ' . $e->N . ', keysym = ' . $e->K . '.'; print "$binding\n"; print $e->K," released\n"; }

      not sure why I (or anyone) bother persisting with using this stuff--it's just painful.

      Well because it is seldom needed to delve into it with any depth.... it's just your mouse and keyboard events and it works almost everytime. So it's like your default keymap defs, I use them all the time, but it's a real pain to try to figure out the low level stuff it involves..... termcap, locale, unicode..... painful.

      Perl/Gtk2 gets even more painful in this regard, because everthing in it is an event, and there are chains-of-events to work thru to get something. By comparison, Tk is easy.


      I'm not really a human, but I play one on earth. Cogito ergo sum a bum