Arjen Markus <
[email protected]> wrote:
On Sunday, January 29, 2023 at 7:57:27 PM UTC+1, Torsten wrote:
I have a context menu for text and entry widgets. When I click the right mouse button, I open it a
the mouse cursor position.
When I press the context menu key, i.e. keysym 'App' for Windows and 'Menu' for Linux and macOS, I
want it to open at the cursor position of the text or entry field.
How do I get the screen coordinates of the cursor position in that case?
You probably want [winfo pointerxy], as that returns the x/y coordinates
of the pointer wrt the screen that holds the window. I do not think I have ever used it myself, so I simply rely on the man page :).
My understanding of the question was, that he wanted the coords of the
widget's "insertion"-cursor - as in: "that blinking thingie"
For an entry widget .e the following might get you further:
lassign [.e bbox insert] px py dx dy
# do some arithmetics to determine the hotspot of that bbox, e.g.:
set py [expr {$py+$dy/2}]
# add the widget's global coords:
incr px [winfo rootx .e]; incr py [winfo rooty .e]
for text-widgets it might be pretty similar...
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)