How to Disable the Preference and About Box Items
dburgun at dsl.pipex.com
Fri Dec 2 08:17:28 EST 2005
>David Burgun wrote:
>>>Since you never wanted to prevent the user from accessing
>>>Preferences anyway, this will get you want you want for the low
>>>cost of a couple milliseconds:
>>> on DisableEditItems
>>> repeat with i = 1 to (the number of lines of btn "Edit"-1)
>>> disable menuitem i of btn "Edit"
>>> end repeat
>>> end DisableEditItems
>>>Instant HIG-compliant Edit menu for all supported platforms in one move.
>>This causes the Preferences Item in the Apps menu to be un-dimmed
>>but unselectable, or rather nothing happens when you select it. The
>>only way I can see of doing this is to use the above loop but check
>>for an Item starting with "Preferences", which is a tad horrid!
>>Same for the about box.
>I'm unable to reproduce that here.
>1. Make a new stack
>2. Add a menu bar with the default items in Rev's Menu Builder
>3. In the Edit menu, for the "Preferences" case I have
> answer "Howdy"
>4. Select Preferences from the Edit menu to check it -- ok
>5. Added a button with this script:
> on mouseUp
> end mouseUp
> on DisableEditItems
> repeat with i = 1 to (the number of lines of btn "Edit"-1)
> disable menuitem i of btn "Edit"
> end repeat
> end DisableEditItems
>6. Click the button
>7. Pull down the Edit menu -- yep, items are disabled
>8. Select Application->Preferences
> -- I get the answer dialog as expected
>What did you do differently?
The Problem may be that I am disabling the items in the preOpenStack
handler, another difference is that I have 4 stacks that affect the
menu in different ways when selected. I will take a look, I'm sure I
can fix this one way or another! Opps! Just spotted the -1 in the
loop! Ok that was probably it. One thing tho, you also need to test
if running under MacOS X for this to work, else under MacOS 9 and
Windows the Preferences Item will be disbaled (which may or may not
be what is required).
IMO, a better way of hanlding this would be to have the Menu
Builder/Rev, make a "special" menu button called something like
"__SPECIAL_ITEMS__". This Item would never be displayed in the
Menubar and would have 2 items (or more as and when they are
needed), the first being the AboutBox and the Second the Preferences.
Then depending on the platform do the following:
For Windows and MacOS 9, move Preferences to the end of the Edit Menu
(placing a seperator before it)
For MacOS X, move Preferences to the Apps menu.
For Windows, Move the About Item to the Help Menu
For MacOS 9, Move the About item to the Apple Menu
For MacOS X, Move the About item to the Apps Menu
Then whenever one of these are selected, the menuPick message is sent to the:
I am not sure of the details of how menu items are handled on the
other platforms supported by Rev, but from what I do know, I think
the above should work ok.
This would be better since, you would have all the "special" items on
one place, and, you can handle them from the same Menu Item Script.
What do you think?
Thanks for your help and have a Great Weekend!
All the Best
More information about the Use-livecode