Tk Source Code

View Ticket
Login
Ticket UUID: bc6a49594908e6af5d15b47b267c6890dcc43386
Title: Documentation bug for upper case %X an %Y binding script substitutions
Type: Bug Version: 8.5
Submitter: erikleunissen Created on: 2019-06-20 18:53:00
Subsystem: 01. Bindings Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-07-05 09:57:13
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2019-07-05 09:57:13
Description:
man bind says for the following two binding script substitutions:

--------------
%X
    The x_root field from the event. If a virtual-root window manager is being used then the substituted value is the corresponding x-coordinate in the virtual root. Valid only for ButtonPress, ButtonRelease, KeyPress, KeyRelease, and Motion events. Same meaning as %x, except relative to the (virtual) root window.

%Y
    The y_root field from the event. If a virtual-root window manager is being used then the substituted value is the corresponding y-coordinate in the virtual root. Valid only for ButtonPress, ButtonRelease, KeyPress, KeyRelease, and Motion events. Same meaning as %y, except relative to the (virtual) root window.
--------------

I can perfectly well use %X and %Y for <Enter> and <Leave> events. But these are not in the list of valid events above.

Just an omission, or is there maybe an undocumented reason why I shouldn't use these substitutions with <Enter> and <Leave> events?

Erik Leunissen
User Comments: jan.nijtmans added on 2019-07-05 09:57:13:
Committed now to all active branches (incl. 8.5)

fvogel added on 2019-07-03 19:43:48:

Well... why not, see [1c5f8d6f53].

Note that several other lists of events are not sorted in that same page (seee description of %d, %h, %m, even %x and %y). Is there really a sorting rule to follow here? I'm not sure.


erikleunissen added on 2019-07-03 17:21:44:
Simple fix, and all right from my point of view.

One remark in the category utter nitpicking:
The corrected set of events happens to be the same as the enumeration for the %s substitution expression, which appears to be ordered alfabetically.

I don't mind if the order is left disregarded.

fvogel added on 2019-07-02 20:16:59:

Fix proposal: [b37c02c4fb]


erikleunissen added on 2019-06-21 18:07:45:
Yes I do have a use case for upper case %X and %Y substitutions:

I've created a Tk application extension that tracks windows in a gui with the mouse pointer. The tracking mechanism is based on <Leave> and <Enter> events, and it reports the detected window's pathname, as well as the position of the mouse pointer.

The position of the mouse pointer, in turn, is used to display a toplevel widget right there, using [wm geometry $w]. And [wm geometry] wants coordinates relative to the (virtual) root window. Therefore, I need the upper case %X and %Y, not the lower case variants.

Aside: I plan to offer this extension to tklib within the next few months, or (if maybe not accepted) publish it myself.

fvogel added on 2019-06-20 21:05:50:

Good point, it seems that the code definitely allows this, see %X,%Y treatment in ExpandPercents, and the meaning of KEY_BUTTON_MOTION_CROSSING. CROSSING is used with <Enter> and <Leave> events.

I believe we are looking at a documentation error, I can't see why it %X and %Y couldn't be used <Enter> and <Leave> events. At least as a principle. In practice I'm not sure it is really useful, %x and %y should be much more useful, but some users might find a use case for %X and %Y as well (apparently you did?).