[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Toolbox] Disabling (not Hiding) items in dialog boxes?



Ian Crew writes 19 May 1999:

>How do you enable/disable (i.e. gray out) items in dialog boxes?  I
>know how to hide and show items (using HideDialogItem and
>ShowDialogItem), but I can't figure out the enable/disable
>equivalents.

As far as I know you cannot do this. It is tempting to think that it might
be possible to change the current 'RGBForeColor()' to a gray and then
re-set the button text. However the machine will crash if you use
'SetDialogItemText()'. 'GetDialogItemText()' is alo broken, returning
garbage prepended to the string.

While on the subject of crashes with Dialogs.pm, beware that if you select
text in an Edit field and then use MenuBar:Copy (or 'Cut' or 'Paste') the
machine will crash. This is not really a bug, but behaviour (frankly
ungraceful behaviour) that reflects the fact that the whole MenuBar is a
property of the MacPerl window, not the Dialog window.

As an alternative to Dialogs.pm, it is nearly always possible (and often
preferrable in my view) to do the job using Windows.pm and Controls.pm. The
problem with changing the text on the button disappears (the bug that
afflicts Dialogs.pm is absent in Controls.pm), but it is still not possible
to 'gray out' the button. But what you _can_ do, is hide the button and
draw your own dummy grayed-out object in the same place. That is very easy
to do in a MacWindow, but not possible in a MacDialog I think.

That still leaves the MenuBar problem. The simplest course of action is to
inhibit all of the menus that are irrelevant or dangerous. For instance the
'Edit' mneu can be grayed-out in its entirety by calling:

    DisableMenuItem(GetMenu(130), 0);

and restored when the dialog window closes by:

    EnableMenuItem(GetMenu(130), 0);

and similarly for the other menus. (You need to 'use Mac::Menus' of course)

Hope these thoughts are some help.

Alan Fry




==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org