On Sat, 14 Jan 2023 12:22:27 -0800 (PST), mikkelstuff wrote:
On Saturday, January 14, 2023 at 10:31:25 AM UTC-7, Luc wrote:
On Fri, 13 Jan 2023 18:26:09 -0800 (PST), mikkelstuff wrote:
I need to capture the screen coordinates when touching a left mouse button. Seems like "canvas" should do this but I just do not see it.
Any other ideas?
bind $canvaswidget <ButtonRelease-1> {$textwidget delete 1.0 end; $textwidget insert end [%W canvasx %x]/[%W canvasy %y]}
or
bind $canvaswidget <ButtonRelease-1> {puts [%W canvasx %x]/[%W canvasy
%y]}
--
Luc
Got it! Sorry but I have not programmed in Tcl/Tk since retirement and am rusty. Ok, rusty geezer. Thanks all
Please note those are not the coordinates of the screen. They are
the coordinates of the canvas, and the canvas has its own idea of what
x and y mean. I believe a canvas puts 0,0 on the bottom right corner
by default, such that everything you can see sits on negative (less
than zero) coordinates. I'm not really sure though. Anyway, you will
probably have to adjust the position of the canvas yourself before
you use it.
For example:
set ::canvaswidget $::w.outer.canvasframe.canvaswidget
canvas $::canvaswidget
$::canvaswidget configure -bg white
$::canvaswidget configure -height 900 -width 1900
$::canvaswidget configure -xscrollincrement 1
$::canvaswidget configure -yscrollincrement 1
$::canvaswidget configure -scrollregion [list 0 -900 19200 0]
$::canvaswidget xview moveto 0.0
$::canvaswidget yview moveto 0.45
Those values are pretty random here since I don't know what you
want or need. Your case will certainly require different values.
--
Luc
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)