[MonoDevelop] Fwd: How to Change Visibility of Menu Items and Toolbar Buttons

Jacek Ruzyczka ruzyczka at versanet.de
Mon Jul 30 15:30:32 EDT 2007


Hi folks,

I've recently tried to implement some menu items and toolbar buttons, which
change visibility depensing on what type of tab is being displayed in a
notebook, which lies in my main window:

		// What ends with 'MI' is a menu item, the remainders are radio buttons.
		protected Gtk.Action recordInsert;
		protected Gtk.Action recordFind;
		protected Gtk.Action recordInsertMI;
		protected Gtk.Action recordFindMI;
		protected Gtk.Action tabBack;
		protected Gtk.Action tabForward;
		protected Gtk.Action tabBackMI;
		protected Gtk.Action tabForwardMI;

		// This method grays out all controls.
		protected virtual void LockRecordControls()
		{
			this.recordFind.Sensitive = false;
			this.recordInsert.Sensitive = false;
			this.tabBack.Sensitive = false;
			this.tabForward.Sensitive = false;

			this.recordFindMI.Sensitive = false;
			this.recordInsertMI.Sensitive = false;
			this.tabBackMI.Sensitive = false;
			this.tabForwardMI.Sensitive = false;

			this.menuBar.ShowAll();
		}

I have also written a method called UnlockRecordControls(), which is
 vitrually the same as LockRecordControls(), but set the visibility of all
 the actions to TRUE.

The constructor of the main window calls LockRecordControls(), as this is
default behavior. However, once a data-aware tab is displayed in the
notebook, UnlockRecordControls() is called.

My problem: After UnlockRecordControls() has been called, all menu items and
toolbar buttons can be used,...but two of them (those named recordXXX...the
others work normally) still remain gray! The icons I'm using are self-made
single-image icons. Full color, of course.

Strange behavior, isn't it?

Regards
Jacek Rużyczka

-------------------------------------------------------


More information about the Monodevelop-list mailing list