0

The idea is how to open popup next to the event button - it's to get Onclick Mouse Cursor Position

It would be like this, when clicking anywhere on the desktop, you should call the program in Tcl/Tk at the mouse pointer location. This Tcl/Tkt program should be without embroidery, window frame.

I know I did it ha good temp ago, in the year 2017, at the time I used Tcl/Tk 8.4 to display only the tk window without frame.

Now I don't remember how I did it and I need someone's help to clear my mind.

Diego Henrique
  • 255
  • 1
  • 16

1 Answers1

0

To get the current absolute position of the mouse pointer, use winfo pointerxy $w (the $w is used to work out which “display” you're talking about in an X11 sense, and is pretty irrelevant these days; you can actually use any window there, but it is a required argument anyway).

To move a (toplevel) window to the pointer, you set its geometry. Combining the two, you get this:

proc movewintoptr w {
    lassign [winfo pointerxy $w] x y
    wm geometry $w +$x+$y
}

You might want to consider offsetting the window a bit. (Exactly how best to do that depends on what you are showing in the window; the code gets very application specific.)


To make a toplevel window that has no decorations, do:

toplevel $w
wm overrideredirect $w 1

Be aware that undecorated windows can't be easily manipulated by the user by default. You have to implement all that part yourself (if it is relevant).

And yes, the wm overrideredirect call should be very soon after the toplevel is created; windows can't usually be swapped between display modes once they're displaying on the screen (and that depends on how window managers work, etc).

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215