Hi David,
I've been thinking about all the topics I missed covering in my scripting
classes, and am considering adding a few more classes to try and cover these
(especially since someone else has written to me with a similar type of
question, and mentioned he wishes I had covered more).
So, while I will try to answer your question now, I'd appreciate it if you
(and others), would note down any such omissions of obvious topics or
questions which I failed to cover adequately, and post them here to the list
(where they might trigger thoughts or ideas in others as well as getting to
me). I'll try to add some further podcasts to the collection.
Working with dialogs and menus is one I know I need to cover further.
In this case, where you should add these lines of code depends entirely on
what triggers changes in the conditions governing whether this item should
be enabled or not.
For instance, if you have a dialog of options, and in there the user chooses
options which cause this menu item to be enabled or not, it would be in the
dialog handler for this dialog where you would add your commands for
enabling the menu item.
If though, it changes based on other choices they may make from the app
menu, then you would add the commands in the menuproc even handler for the
app menu.
Finally, if it's based on entries you may find in the related .ini file for
the app, then you would add the commands in the code after you read from the
.ini file.
The only requirement is that you execute these commands sometime after the
app menu has been displayed with the call to the "menu" function (where the
MyMenu variable is initialized).
The command may only be a single line like the one below:
MyMenu.enabled("mymenuitem") = ConditionMet
If your menu item is contained within a submenu, then you'll need some
commands like the ones below, to get to the submenu (in this example, it's
assumed your item is contained in a submenu named "options"):
Set OptionsMenu = MyMenu.GetSubmenu("options")
OptionsMenu.enabled("mymenuitem") = ConditionMet
And if it's several levels of menu down, then you'll need to repeatedly make
use of the .GetSubmenu() function until you get to it.
I hope it's clear, that once your app menu has been displayed, you can place
these commands anywhere you like; where-ever it makes the most sense, which
is generally when the conditions are changed.
Hth,
Chip
From: David [mailto:[email protected]]
Sent: Tuesday, November 26, 2013 9:28 PM
To: [email protected]
Subject: Disabling a menu choice - how to?
Developers,
I could need a bit of educated assistance, please.
I have an app, that was started out by using the WEScript Framework app.
I wanted to add a choice to the app menu of my app, and for the ease we will
call it
MyMenuItem.
I entered the necessary information in the XML file, and modified the
MenuProc function in the app code - so it knows how to handle things, once
my new entry is selected. Everything works just like expected, this far.
Where my knowledge stops, is here. I want to make the new menu entry
available, only under certain conditions. Say for instance, I have a Boolean
variable, named
ConditionMet
and only want to display the entry on the app menu, when this variable is
true. Cook it all down to something like this:
If ConditionMet Then
' Need the code to make the menu entry visible.
Else
' need the code to make the menu entry disappear.
End If 'ConditionMet.
Allright, I know, it may not be all that simple. A couple of years of app
development, has taught me there likely will need to be a few lines extra of
codeing. Smile. Yet, I hope the above explains where my trouble has its
nest.
More exactly, which variables (properties and methods), should I make use of
- so as to have the menu entry show up, and disappear. And, in the code,
where would I put the extra lines. As stated, the naked frame of the app,
was designed by WEScript Framework. So, if you happen to know exactly in
which Sub or Function the modification will be needed, I would be saved an
hour of searching through the lines of code. Smile.
Thanks for any ideas and input.