[fxruby-users] How do I grey out or hide menu items.
Lyle Johnson
lyle at lylejohnson.name
Fri Mar 7 12:11:14 EST 2008
On Mar 7, 2008, at 8:55 AM, datatec wrote:
> I see from a lot of places that:
> Menu commands may reflect the state of the application by graying
> out or
> becoming hidden.
>
> But how exactly would I do that?
The standard way to do this is to catch the SEL_UPDATE message that
the menu command button sends to its target.
> So for example
> Here I have a command that I do not want enabled until changes have
> been
> made to a document
>
> savefile=FXMenuCommand.new(filemenu, "&Save\tCtl-S\tSave the
> file.").connect(SEL_COMMAND) {
> filesave
> }
>
> how could I set this to greyed out and/or hidden?
Here's what I'd do:
savefile.connect(SEL_UPDATE) do |sender, sel, data|
if document.changed?
sender.enable
else
sender.disable
end
end
> General question. I can seem to find a lot of API and CLASS stuff but
> documentation of simple things like the above seem to be missing.
> Am I just
> looking in the wrong place?
There's a good bit of free documentation at the FOX web site (http://www.fox-toolkit.org/
), and although it's geared toward users of the C++ FOX library, you
may be able to get a lot out of it. The best source for in-depth,
tutorial-style documentation of FXRuby is the new FXRuby book (see my
sig for details).
Hope this helps,
Lyle
---
"FXRuby: Create Lean and Mean GUIs with Ruby"
Now available as a Beta book from the Pragmatic Bookshelf
http://www.pragprog.com/titles/fxruby
More information about the fxruby-users
mailing list