mmartin has asked for the wisdom of the Perl Monks concerning the following question:

Hey Monks!

I'm writing a Gtk2 script and I'm trying to do something that might seem a little strange...

I know how to add mnemonic label to a button and allow that to be used to select that button. i.e. "_Close" will have the Accelerator Key
combination of "Alt+C" to select that button. But is it possible to add a Accelerator Key-Combo (mnemonic) to a button which doesn't contain
a Label INSIDE the button..?

The reason I don't have the mnemonic Label inside the button is because I was trying to make everything in my script look fairly uniform. And in
my script I have a few different areas inside the "Window" that contain a Frame, and inside the frame is a HBox containing a Label and Entry. I have
about 4 different sections of the Window (*populated using Gtk2::Table) that are like this, so in the new "Framed" area I have a Button instead
of a Entry, which opens a ColorSelectionDialog. And next to the Button is a Label, exactly like the ones containing a Label and Entry...
         *FYI, the Button contains a DrawingArea set to the ColorSelection of the User.

So is it possible to add this mnemonic 'action' to a button that doesn't contain a Label inside it?
Or maybe even include a Label but somehow Hide it/prevent it from displaying..?


Any idea if something like this is possible?


Thanks in Advance,
Matt


  • Comment on Perl Gtk2: Key Accelerators for Buttons

Replies are listed 'Best First'.
Re: Perl Gtk2: Key Accelerators for Buttons
by Anonymous Monk on Aug 08, 2013 at 09:28 UTC

    But is it possible to add a Accelerator Key-Combo (mnemonic) to a button which doesn't contain a Label INSIDE the button..?

    Yup, all that accelerator stuff does is add a key listener, and connects a signal to a specific key combo

    You can do that without a label, label just saves you typing

    Cheapest/Easiest way is to create a menu, and associate hotkeys with the same action/callback/signal as the buttons

      Hey Anonymous Monk, thanks for the reply!

      Humm, that's a good idea... I thought I remember seeing something about Accelerators when looking over
      some Tutorials/Reference Guides.

      I just looked it up and found it on the couple sites I've been using as reference guides.

      Here's One:
             --> http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/Accelerator.html

      And Here's a BETTER one with actual explanations of everything, which was actually hard to find when I first
      started this script. It's not the same Object/Widget as the other link, but this site in general has GREAT
      explanations of all the Widgets and their Methods/Functions:
             --> https://developer.gnome.org/gtk2/2.24/gtk2-Accelerator-Maps.html


      Thanks again for the reply Anonymous Monk, I'll most likely be adding a Menu bar and assign the Accelerators
      within there, like you suggested...


      Thanks Again,
      Matt