• How to bind to a ttk::menubutton?

    From Mark Summerfield@m.n.summerfield@gmail.com to comp.lang.tcl on Mon Jul 28 09:55:01 2025
    From Newsgroup: comp.lang.tcl

    Tiny eg

    #!/bin/env wish9
    ttk::menubutton .moreButton -text More -underline 0
    menu .moreButton.menu
    .moreButton.menu add command -label Test -underline 0 \
    -command {puts "Test"}
    .moreButton configure -menu .moreButton.menu
    pack .moreButton
    bind . <Escape> {exit}
    bind . <Alt-m> {.moreButton invoke} ;# WRONG!

    If I click the More button the menu pops up and works correctly.

    But I cannot see how to do a binding that will make the menu
    pop up when I press <Alt-m>. How can I do this?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mark Summerfield@m.n.summerfield@gmail.com to comp.lang.tcl on Mon Jul 28 10:02:27 2025
    From Newsgroup: comp.lang.tcl

    On Mon, 28 Jul 2025 09:55:01 -0000 (UTC), Mark Summerfield wrote:

    Tiny eg

    #!/bin/env wish9
    ttk::menubutton .moreButton -text More -underline 0
    menu .moreButton.menu
    .moreButton.menu add command -label Test -underline 0 \
    -command {puts "Test"}
    .moreButton configure -menu .moreButton.menu
    pack .moreButton
    bind . <Escape> {exit}
    bind . <Alt-m> {.moreButton invoke} ;# WRONG!

    If I click the More button the menu pops up and works correctly.

    But I cannot see how to do a binding that will make the menu
    pop up when I press <Alt-m>. How can I do this?

    Sorry, just saw how to do it. The bind is:

    bind . <Alt-m> {tk_popup .moreButton.menu %X %Y}
    --- Synchronet 3.21a-Linux NewsLink 1.2