[Haskell-beginners] How to switch off a RadioMenuiItem?

Pierre Michallet p.michallet at free.fr
Sun Aug 26 22:50:09 CEST 2012


Using Glade, I have created a menu which,among other things,has 2 radioMenuItems located in the same submenu.
Both are in the off state when the program starts.
In the following, I will refer to them as "initiationCB" and "beginnerCB".
The expected behavior is that these 2 options are exclusive ie clicking one when in the OFF state will turn it ON and turn the other OFF.
In fact, the first time I click on "initiationCB" its associated checkbox is turned ON; a second click on it will not change its state.  
When "beginnerCB" is then clicked, it is turned ON but "initiationCB" is not turned OFF as expected, and from then on, the two items are ON and there is no way to  turn them OFF.
One surprising thing is that in the same menu there are 2 CheckMenuItems which, when clicked, change their state without any code written to obtain this behavior.
I would have expected the same from RadioMenuItems.
In an attempt to switch a RadioMenuItem OFF , I have added the following code:

                  on initiationCB menuItemActivate
                       do  checkMenuItemSetActive initiationCB True

When "initiationCB" is clicked (and turned ON as a consequence) the program blows up seeming in an infinite recursion.

The Gtk2HS tutorial (chapter 7.2) gives an example of selective choices by defining actions in the file called by a UIManager to get the elements of the user
interface and RadioActionEntry in the code.
The problem is that I could not succeed in associating an action to a menu item in the Glade file (as done in the tutorial), and in case of success, I don't know whether a
XmlGetWidget instruction would recognize it.

So the question is : is there a way to implement a solution similar to the one described in the tutorial using Glade instead of the UIManager approach?

Another odd thing to me is that the signal menuItemToggle is not raised when a radioMenuItem is clicked.

Thanks in advance for your help

p.michallet at free.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120826/d03a26ba/attachment.htm>


More information about the Beginners mailing list