[Gambas-user] Radio menu item

Tobias Boege taboege at ...626...
Mon Sep 8 17:23:20 CEST 2014


On Mon, 08 Sep 2014, Patrik Karlsson wrote:
> I was looking for a way to have menu items behave like radio 'buttons' and
> the only thing I found was an old archive post from 2009.
> http://sourceforge.net/p/gambas/mailman/message/24068134/
> 
> Is it possible to have radio menu items now?
> 
> /Patrik
> 
> I guess I could make "Toggle" menu items behave like a radio group but I
> don't like that idea.

Why not? How else would you signify to your user that it's not an ordinary
menu? Do you know if the traditional look of RadioButtons is supported in
menus in QT and GTK? Even Kate -- which is what comes to my mind when I
think about monstrous menus -- has this CheckBox-like look for RadioButton-
like menus (in the version which I use).

Attached is a project that implements such RadioButton-like menus using a
hack (because the IDE menu editor doesn't seem to be extensible enough to
manage custom properties of the Menu class -- nobody would expect the IDE to
be able to do that!): it uses the Tag field of the menus. You can make your
Menu a Toggle = True one and set the Tag to a string like "Radio:<GroupName>".

Then, whenever such a Menu is activated, all other menus of the same group
(in the same window) are de-activated.

It also overrides the native Menu class to integrate seemlessly and let you
work with the IDE menu editor. If you can dismiss that, you can make the
code cleaner, of course.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RadioMenu-0.0.1.tar.gz
Type: application/octet-stream
Size: 4612 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20140908/2ed75560/attachment.obj>


More information about the User mailing list