Autore Topic: Menu Radio  (Letto 319 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.316
  • Ne mors quidem nos iunget
    • Mostra profilo
Menu Radio
« il: 08 Settembre 2014, 20:25:01 »
Vi riporto questa discussione:


" 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
"


" 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
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »