Thanks to all who responded.

Unfortunately, it seems things are not yet as easy as I hoped for.Smile.

OK,   MyMenu.Enabled( "SupportByEmail") = False
  MyMenu.Grayed( "SupportByEmail") = True
I have found a way to Grey out the menu entry, and also Disabling it:
    MyMenu.Enabled( "MyId") = False
    MyMenu.Grayed( "MyId") = True

This all works for now, although the menu entry would still be in the list, 
when you scroll through the menu.


Then, you informed me about the three promising methods:
    GetSubMenu,
    
Delete,
and
    InsertMenu.

It sounded like what I wanted, and maybe it is. Yet, I did not get it to work.

I tried to use the GetSubMenu to retrieve my XML defined menu entry, and then 
store it in a local variable. Thereby, I hoped to be able to quickly insert it 
at a later time, should the conditions change.

Well, see that does not work. Why? Well, my menu entry actually is a submenu, 
holding three items. And if I do something like:
    Dim TempMenu: Set TempMenu = MyMenu.GetSubMenu( "MyID")
' this will sure enough store a menu object in the TempMenu.
    MyMenu.Delete( "MyID")
' Yep, it deletes the entry, from what I exprience.
    MyMenu.InsertMenu 
' Hmmm, here we get in trouble. I cannot just do something like:
    MyMenu.InsertMenu( TempMenu)
' Why? because the InsertMenu takes three parameters, and none of them are an 
object. They are two strings, The Text and ID of the menu entry to insert, and 
then a numeric parameter. If I am to do it this way, I would have to First 
Re-initiate the menu entry, and then re-initiate the three subitems of that 
submenu, one by one. And that will be quite a lot of coding, since I would have 
to get hold of each item's Text, and their individual ID. So, unless someone 
could prove me wrong here, I guess I am better off simply to disable the 
submenu for now.

Hope all of this makes sense. And GW, would it be possible in later versions of 
the ToolKit, to have a feature to insert a whole submenu that you temporarily 
have disabled? Or, I should have said Deleted.

Thanks again, everyone.


  ----- Original Message ----- 
  From: Chip Orange 
  To: [email protected] 
  Sent: Wednesday, November 27, 2013 6:00 PM
  Subject: RE: Disabling a menu choice - how to?


  Rod and David,

   

  After reading Rod's reply, he's quite right; you could add or delete a menu 
item in the same way I was using the .enable property.  I never thought  that 
could be what you meant with your question, but now that rod mentions it, it's 
just as valid an interpretation.

   

  I can't think of any reason why adding and deleting menu items is any less 
desirable than enabling or disabling them.

   

  Chip

   

   

  From: Rod Hutton [mailto:[email protected]] 
  Sent: Wednesday, November 27, 2013 11:15 AM
  To: [email protected]
  Subject: Re: Disabling a menu choice - how to?

   

  Hello David,

  Normally, as I've learned from Chip's classes (see class 13), you check or 
uncheck menu items, and you can also disable and enable them, as necessary.

  However, having looked at the manual, it is possible to remove and insert 
menu items as well.  I've never used this approach in any of my apps, but I 
suppose it is one approach.  I've pasted the relevant info from the manual FYI.

  hth,

  Rod Hutton

  Navigation:
  The Window-Eyes Object Model
   >
  Objects
   >
  Menu
   >
  Methods
  Previous page
  Return to chapter overview
  Next page
  Menu
   object methods allow you to perform actions on a
  Menu
   object.
  Methods
  ·
  Delete
  ·
  GetSubMenu
  ·
  InsertItem
  ·
  InsertMenu
  Requirements
  Window-Eyes 7.1 or greater.

  On 11/26/13 9:28 PM, David wrote:

    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.

   

Reply via email to