Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks choroba for looking at my code.

> Canvas is designed to make moving objects around with a mouse easy. Therefore, when you press a button and start moving the mouse, the current is the canvas object that you're moving, i.e. it doesn't change as you move the mouse pointer over the grid.

The above seems very reasonable but i doubt is true: infact, if true, how can my code work? I currently have:

$canvas->Tk::bind("<Control-Motion>", [ \&set_coord, Ev('x'), Ev('y') ]);

and this code actually draws on the canvas and the element tagged as current changes as you move the pointer (you can also see the debug messages on the console like SET 22 - 14 and so on)

So with the Control modifier it works and as Button1 is stated as a valid modifier I expected to work in the same way. Here my working binding and all tries:

$canvas->Tk::bind("<Control-Motion>", [ \&set_coord, Ev('x'), Ev(' +y') ]); #no just the first: #$canvas->Tk::bind('<Button1-Motion>', [ \&set_coord, Ev('x'), Ev( +'y') ]); # no just the first #$canvas->Tk::bind('<B1-Motion>', [ \&set_coord, Ev('x'), Ev('y') +]); # wrong: extra characters after detail in binding at #$canvas->Tk::bind('<Button-1-Motion>', [ \&set_coord, Ev('x'), Ev +('y') ]); # wrong: bad event type or keysym "Button1" #$canvas->Tk::bind('<Button1><Motion>', [ \&set_coord, Ev('x'), Ev +('y') ]); # ok after Button-1 (not holding it) until for example Button-3 #$canvas->Tk::bind('<Button-1><Motion>', [ \&set_coord, Ev('x'), E +v('y') ]);

The last one is intriguing: it seems to be not a modifier but more a sequence. Anyway I'm happy with <Control-Motion> less carpal tunnel ;)

> To make the sterling and degree work, you must save the script as UTF-8 and add use utf8; towards the top.

Tadąaa! thanks! adding use utf8; on top made sterling and degree to work as expected. My utf8 foo is near to zero.. I did not even suspected the issue.

I've update my code with it ;)

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re^2: Tk ASCII Draw on Canvas by Discipulus
in thread Tk ASCII Draw on Canvas by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (9)
    As of 2019-10-14 22:52 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?