Bind Mouse button on tree widget - hwtk::treectrl

User: "vipin_22401"
Altair Community Member
Updated by vipin_22401

Hi all,

 

Is it possible to bind mouse button operations on hwtk treectrl widget?

For example I have created a tree like below, when i click on any item, it should act as a button and execute some command.

 

image.png.0792975ac3fda25b9b479f3f75be8a2b.png

 

Find more posts tagged with

Sort by:
1 - 5 of 51
    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Vipin

    did you try setting a callback for option -selectcommand when creating the treectrl ?

    when you select some thing it will invoke -selectcommand

    User: "vipin_22401"
    Altair Community Member
    OP
    Updated by vipin_22401

    Hi @tinh

     

    I added -selectcommand as you said.

    Anything I select in the tree it is running that command, but how do I assign different script/command for each of the buttons?

     

     

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi Vipin

    example 

    set t [hwtk::treectrl $treewnd -selectcommand 'p_AtSelected %W']

    proc p_AtSelected t {

         set items [$t select]

         #you may select more than 1 item so pls handle it

          foreach item $items {

               set text [$t item text $item 0]

               switch -- $text {

                     button1 {

                           ...

                      }

                      button2 {

                           ... 

                       }

                       ... ...

                 }

            }

    }

    User: "vipin_22401"
    Altair Community Member
    OP
    Updated by vipin_22401

    Hey tinh,

     

    Thanks a lot for the help. It is working perfectly!!

    I Added -selectmode single, so multiple selection solved :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

    User: "Altair Forum User"
    Altair Employee
    Updated by Altair Forum User

    can u share me this macros