Disabling Menu Items At Runtime

I do not seem to be able to disable menu items at runtime. I have tried using all sorts of events to get this to work. I have a menuitem that shows up in autocomplete and so does the enabled property. What I am trying to do is disable the FileSave menu item at runtime of no modifications have been made to the document. Here is my code:
FileSave.Enabled=DocumentModified

//it tells me item does not exist highlighting ‘enabled’. Do I need to make my menu item at runtime or something.

Another question I have got is how would I be able to make a project file for my app. How does saving and opening project files work with the Xojo IDE? Does it encrypt the project file and if so why. If I wanted to keep things simple could I just use XML?

Thanks

You are better off creating multiple topics for multiple questions, it is easier to respond and track that response 6 months later when someone else has the same problem.

As for your menu item problem. Are you sure that you named your menu item FileSave? What does tab completion give you? I enable/disable menu items all the time using .Enabled in various places in code as well as the EnableMenuItems event.

as to your second question… Xojo will save files in 3 different formats (assuming you have a paid license)

  1. Binary format… this is probably the “encrypted” file you are referering to.
  2. XML format
  3. VC format (version control)

but only format #1 is available for your use with the FREE IDE version.

[quote=24014:@Jeremy Cowgar]You are better off creating multiple topics for multiple questions, it is easier to respond and track that response 6 months later when someone else has the same problem.

As for your menu item problem. Are you sure that you named your menu item FileSave? What does tab completion give you? I enable/disable menu items all the time using .Enabled in various places in code as well as the EnableMenuItems event.[/quote]
Thanks for your input. I am sure that is what I named my menu item, it even comes up in the autocomplete menu.

[quote=24017:@Dave S]as to your second question… Xojo will save files in 3 different formats (assuming you have a paid license)

  1. Binary format… this is probably the “encrypted” file you are referering to.
  2. XML format
  3. VC format (version control)

but only format #1 is available for your use with the FREE IDE version.[/quote]
Thanks for your input. What are the VC and binary formats for? As I am making my own software that handles project files. Also how would I make an installer that makes a file association with software, if you know? Thanks in advance.

also… I have noticed on menu items that AUTOCOMPLETE gives ENABLE but the property you need to change is ENABLED
so make sure that is also set properly

For the fun of it, instead of using DocumentModified insert a True and see if that makes things work. Is DocumentModified visible? Is it a Boolean type? If you can’t solve it playing with those two, then I’d say you found a bug.

[quote=24022:@Dave S]also… I have noticed on menu items that AUTOCOMPLETE gives ENABLE but the property you need to change is ENABLED
so make sure that is also set properly[/quote]

Yeah, .Enable is a method on the MenuItem, so auto complete stops at that point and will make you choose .Enable() or .Enabled… I’ve been caught many times Menu.Enable = True/False instead of the proper Menu.Enabled = True/False

[quote=24022:@Dave S]also… I have noticed on menu items that AUTOCOMPLETE gives ENABLE but the property you need to change is ENABLED
so make sure that is also set properly[/quote]
Yes that is all good. I will literally copy and and paste the code as it is written: ‘FileSave.Enabled=DocumentModified’, this is found in the event handler, EnableMenuItems on my project.

[quote=24024:@Jeremy Cowgar]For the fun of it, instead of using DocumentModified insert a True and see if that makes things work. Is DocumentModified visible? Is it a Boolean type? If you can’t solve it playing with those two, then I’d say you found a bug.

Yeah, .Enable is a method on the MenuItem, so auto complete stops at that point and will make you choose .Enable() or .Enabled… I’ve been caught many times Menu.Enable = True/False instead of the proper Menu.Enabled = True/False[/quote]
Either way it won’t work. Damn bugs in Xojo. I am sick of using the feedback system. Thanks

[quote=24024:@Jeremy Cowgar]For the fun of it, instead of using DocumentModified insert a True and see if that makes things work. Is DocumentModified visible? Is it a Boolean type? If you can’t solve it playing with those two, then I’d say you found a bug.

Yeah, .Enable is a method on the MenuItem, so auto complete stops at that point and will make you choose .Enable() or .Enabled… I’ve been caught many times Menu.Enable = True/False instead of the proper Menu.Enabled = True/False[/quote]
Is there anyway I can workaround the bug?

I have a hard time seeing this as a bug… since I have no problem doing this (in the manner you are describing)… and Jeremy doesn’t seem to indicate he has an issue either.

So at this point I would submit that there is something else in your program… that is either causing the .ENABLED flag to never be changed, or is changing it back at some other point

Dave is right, I have a hard time seeing this as a bug. Did you try FileSave.Enabled = True and see if that works? If that works, then there is a problem somewhere with your DocumentModified. I use .Enabled all the time w/o any issue what-so-ever.

Hm, just saw your response, the screen here didn’t update.

How large is your project? Is it private? Could you post a .xojo_binary version of it somewhere online? Have you tried creating a new desktop app that is blank, to Window1 add in the EnableMenuItem event, FileQuit.Enabled = False and see if that works? (you’ll have to kill the app via the debugger).

[quote=24041:@Jeremy Cowgar]Hm, just saw your response, the screen here didn’t update.

How large is your project? Is it private? Could you post a .xojo_binary version of it somewhere online? Have you tried creating a new desktop app that is blank, to Window1 add in the EnableMenuItem event, FileQuit.Enabled = False and see if that works? (you’ll have to kill the app via the debugger).[/quote]
It seems that the bug it is the menubar causing this. Give me a sec and I will post it.

[quote=24041:@Jeremy Cowgar]Hm, just saw your response, the screen here didn’t update.

How large is your project? Is it private? Could you post a .xojo_binary version of it somewhere online? Have you tried creating a new desktop app that is blank, to Window1 add in the EnableMenuItem event, FileQuit.Enabled = False and see if that works? (you’ll have to kill the app via the debugger).[/quote]
http://www.mediafire.com/?ahi16c1facq75e9

OK… Here is the problem. You are setting Index, which creates a control index. You need to access those as FileSave(0).Enabled=True, blah, blah, blah. I, however, don’t think that is what you want. It seems you are setting .Index incrementally, as assigned in the position of the menu.

I do not know the reasoning behind the number, but update your .Index properties in the menu editor to be: -2147483648. That should cause everything to start working. Maybe someone from Xojo, Inc. such as @Norman Palardy could chime in on the number significance. I got that number by adding a new menu item and copying it’s default value.

So, in the end, this is not a bug but a misleading number in the .Index property, appearing in red making one think it is an error and probably lead to you putting a more sensible value in its place, but incorrect value. I believe that if the number is -2147483648 that the field should simply be blank. Xojo could interpret a blank index to whatever it wanted, -2147483648 or some other number if it likes. That would alleviate the confusion.

99% of the time the index should be left alone…
but there are times when a ControlSet of MenuItems is desired/required [for example MRU menus (most recently used)…where you want to show a list of files in your menu)
But if YOU do change the index… you need to only increment the value if the menu names are the same (myMenu(1), myMenu(2))
If they are discrete menus… let the index be.

[quote=24055:@Dave S]99% of the time the index should be left alone…
but there are times when a ControlSet of MenuItems is desired/required [for example MRU menus (most recently used)…where you want to show a list of files in your menu)
But if YOU do change the index… you need to only increment the value if the menu names are the same (myMenu(1), myMenu(2))
If they are discrete menus… let the index be.[/quote]
Thanks