Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

A TableMatrix row selection question

by Anonymous Monk
on Aug 29, 2014 at 03:20 UTC ( [id://1098942]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks,

This is a TableMatrix row selection question. I noticed that there is a four year old thread on this http://perlmonks.com/?node_id=840707. However I later felt that it is better to post it as a new question

1. Where do I find what are all the fields that a Perl/Tk programmer can access from an XEvent object and what do those fields stand for? (Mastering Perl/Tk book by Oreilly Press doesn't give any details except Chapter 15 http://oreilly.com/catalog/mastperltk/chapter/ch15.html merely makes a mention of it when accessing 'K' and 'N' for keysym text and decimal). I also looked at Widget.pm which has following line
sub XEvent { shift->{'_XEvent_'} }
but I'm unable to go any further than this to understand the same.

2. In the selectionSet and selectionIncludes methods the above specified thread used the values: '@' . $Ev->x . "," . $Ev->y what does this @ and the full expression stand for. I could not find anything in the perldocs for TableMatrix (and other widgets like TList decendants which also have these methods).

As I'm still trying to learn Perl and Perl/Tk I had to spend few hours trying to look around but to no avail. Therefore any information would be very useful. Many Thanks

Replies are listed 'Best First'.
Re: A TableMatrix row selection question
by stefbv (Curate) on Aug 29, 2014 at 07:37 UTC
    As I'm still trying to learn Perl and Perl/Tk...

    So do I :-)

    1. The fields are from the event data structure of the x11 window system. From "The Xlib Manual", "Chapter 10: Events", 10.2 Event Structures:

    typedef union _XEvent { int type; /* must not be changed */ XAnyEvent xany; XKeyEvent xkey; XButtonEvent xbutton; XMotionEvent xmotion; XCrossingEvent xcrossing; XFocusChangeEvent xfocus; XExposeEvent xexpose; XGraphicsExposeEvent xgraphicsexpose; XNoExposeEvent xnoexpose; XVisibilityEvent xvisibility; XCreateWindowEvent xcreatewindow; XDestroyWindowEvent xdestroywindow; XUnmapEvent xunmap; XMapEvent xmap; XMapRequestEvent xmaprequest; XReparentEvent xreparent; XConfigureEvent xconfigure; XGravityEvent xgravity; XResizeRequestEvent xresizerequest; XConfigureRequestEvent xconfigurerequest; XCirculateEvent xcirculate; XCirculateRequestEvent xcirculaterequest; XPropertyEvent xproperty; XSelectionClearEvent xselectionclear; XSelectionRequestEvent xselectionrequest; XSelectionEvent xselection; XColormapEvent xcolormap; XClientMessageEvent xclient; XMappingEvent xmapping; XErrorEvent xerror; XKeymapEvent xkeymap; long pad[24]; } XEvent;

    2. $Ev->x and $Ev->y are the coordinates of the pointer, I don't know what does '@' stand for, the syntax is from the demos of the Tk::TableMatrix module.

Re: A TableMatrix row selection question
by Anonymous Monk on Aug 29, 2014 at 08:29 UTC
Re: A TableMatrix row selection question
by zentara (Archbishop) on Aug 29, 2014 at 16:11 UTC
    Where do I find what are all the fields that a Perl/Tk programmer can access

    See perldoc Tk::bind and perldoc Tk::bindtags.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      My thanks to zentara, anonymous monk and stefbv for taking time to respond to my questions. I had problems with my internet connection. So couldn't respond earlier. Anyway, from your responses, I now understand,


      1. perldoc Tk::bind under section: BINDING CALLBACKS AND SUBSTITUTIONS list all the fields that are accessible to a Perl/Tk programmer from XEvent object

      2. The symbol @ in selectionIncludes('@' . $Ev->x.",".$Ev->y) has no special meaning but only what it is literally in spoken English (ie. @ simply means "at" and nothing to with array data type) I hope this understanding of mine is correct.

      However, I'm still having difficulty in understanding three lines of the code in http://perlmonks.com/?node_id=840707 viz:
      1. $w->selectionIncludes( '@' . $Ev->x . "," . $Ev->y )
      2. $w->selectionSet( '@' . $Ev->x . "," . $Ev->y )
      3. my ($rc) = @{ $w->curselection };

      As I've no background knowledge of pure Tcl/Tk, I'm unable to undertand what is said in the perldoc on Tk::TableMatrix with respect to these three selection methods. Can you folks please let me know what do these lines do (and how does it highlight the row and clicking on it retrieves the row number) from a Perl/Tk programmer perspective.

      The line @{ $w->curselection } is baffling for me. Also commenting out the binding for <FocusOut> event doesn't appear to affect the program. Why is this so ?

      Thanks in advance.
        I'm still having difficulty in understanding three lines of the code:
        1. $w->selectionIncludes( '@' . $Ev->x . "," . $Ev->y ) 2. $w->selectionSet( '@' . $Ev->x . "," . $Ev->y ) 3. my ($rc) = @{ $w->curselection };
        Sometimes its just better to accept some things as internal magic. :-)

        What I believe what is happening is that since it is in the sub for Motion, it is resetting the Ev at a low level so that the eventloop always picks up the change. Just regard it as low-level manipulation of the widget, which is rarely seen up at the Perl programmers vantage point.

        Have you tried commenting them out to see what effect each line has? Maybe perl/tk HLIST selections options will shed some light.


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1098942]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found