Jump to content
Sign in to follow this  
axs

How to bind mouse button

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 . )


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...