How to bind mouse button
Altair Forum User
Altair Employee
Hello
I'm newbie here and I'm still learning tcl/tk and I have problem with bind function in hypermesh.
I would like to run a function when the user clicks the left mouse button. For example I want to read position of pointer.
I'm using bind function:
bind . <Button-1> {myProc}
The problem is that it doesn't work when I click mouse button in graphic area. It works fine when I click toolbars or tab areas, but I want to run my function if I click anywhere in HM window.
Instead of Button-1 I can use space button in my bind function:
bind . <Key-space> {myProc}
It works well but it's pointless and you have to use keyboard.
Any idea or suggestions how to deal with this?
Thanks a lot for help
Regards
0
Answers
-
Hi,
graphic area belongs to core application and has it own binding (ex: to select elements, nodes,.. by mouse)
should not (and may not be able to) add binding to it
key binding also should be assigned via hypermesh, not directly by tcl-tk (menu Preferences/Keyboard Settings)
whenever you want to get pointer position you can use winfo command:
set x [winfo pointerx .]
set y [winfo pointery .]
assign binding directly just should be done for local window (not root window . )
0