Menu Items

Hello,

I am having an odd problem, I have made a window & added a menu bar with a menu item. When i go to check if the menu item has been checked with;

if debug.checked= true then

I get the error that method does not exist.

I have made the window, menu bar, menu item (menu item name is debug) and the above code is in the apps menu handlers with a new handler called debug

whats more confusing is I have copied the code & everything from a program i made which everything worked fine in;

[code] if debug.checked=true then
wiring.checked=false
msgbox(“Debug Mode Disabled”)
debuginfo=0

else
debug.checked=true
msgbox(“Debug Mode Enabled”)
debuginfo=1
end if
Return True[/code]

The above code is in the menu handler of debug in the working program

I have copied everything over exactly and see no reason why 1 would work while the other will not?

Edit:

forgot to mention that in the error the it highlights debug out of

if debug.checked= true then

[quote=113213:@David Smith]

if debug.checked= true then

I get the error that method does not exist.[/quote]
This means that there is no menu item with the name “debug”.

but there is…

otherwise how could i run the code in the menu handler “debug” ?

In MenuBar1 I have a Menu with Debug Mode as an item below it the properties for Debug Mode are;

Name: debug

Text: Debug Mode

Autoenable: Checked

under the app tab, under Menu Handlers I have;

debug

within this is the above code which is causing the error

On the line where the compiler stops there is only one method and that is the method named with the name of the menu item. The Xojo IDE / framework creates a global method for each menu item in each menu bar. I can’t think of another reason for that error message.

how would i fix this?
I just want to be able to check if the menu item is checked or not

If you start typing somewhere in a method

deb

does autocomplete suggest “debug”?

yes it does suggest debug

You have to set the menu bar! Either on App or on the window you have implemented the menu handler.

On Windows 7, Xojo 2013r2, in a new Desktop project in Window1, MenuBar1 is included with default Edit menu item on the menubar. While editing the “MenuBar1” in GUI, a new menu item is added under the (“Edit” menu) by using the “Toolbar” button (that has tooltip text = “Create a new item in this menu”). This new menu item is given the “Name = debug” and “Text = Debug Mode” and Enter key is pressed. Then select the Window1 from the Project tree and from Xojo menu select “Insert - Menu Handler” and from the Inspector “MenuItem Name” choose “debug” and add the following code above the instruction “Retun True”.

  If debug.checked = True Then
    MsgBox("Debug On")
  Else
    MsgBox("Debug Off")
  End If

The above compiles and executes without any errors.

If you have set the menu bar and done as Syed said and it still is weird then do a restart. Best of the computer, not just Xojo.

Every few months I get some really wonky behavior and a restart usually fixes it. Bob Keeney and Christian have made similar experiences (Bob even wrote a blog post about it)

Thanks for the replies,

Firstly I have the menu bar set to the window, other menus on it worked fine (ones that werent needing to look to see if it is checked)

I have restarted my Pc still doing this.

Further information;

I am running on Win 8.1 (with classic shell) & Sorry i forgot to mention this before I am running Real Studio 2011 R4.3 (personal edition)

I’ve just made a new desktop application and added in a menu item to the edit menu,

It compiles with the code;

if debug.checked=true then msgbox("True") end if Return True

but it never displays the message box? no matter how many times i click it?

I am unable to make it ‘check’

Just a hunch and I will not test it for you, but what if ‘debug’ was somehow reserved ? Have you tried with ‘DebugMNUItem’ ?

Same issue

I am going to see if I can get it to work properly with a whole new app (think I know where i went wrong with the new app above)

Just made a new file & copied the code across & all works fine?

I’m guessing theres some problem with my current file?

might just have to re-make the program

[quote=113292:@David Smith]Same issue

I am going to see if I can get it to work properly with a whole new app (think I know where i went wrong with the new app above)[/quote]

Good thinking. Starting anew is usually the way to avoid previous mistakes.

Ok so I have remade to program and have literally copied and pasted all the code over & set everything up the same

and it works perfectly O_O…so confused but hey it works so im happy :smiley:

[quote=113289:@David Smith]I’ve just made a new desktop application and added in a menu item to the edit menu,

It compiles with the code;

if debug.checked=true then msgbox("True") end if Return True

but it never displays the message box? no matter how many times i click it?

I am unable to make it ‘check’[/quote]
Add the following (or required) code in Window1.Open event to set the initial Checked status of the “debug” menu item.

// // Mark MenuBar1-EditMenu-debug as Checked at startup // debug.Checked = True
And update the handler code for “debug” menu item as shown below to allow the toggle of “Checked” and “Unchecked” at each successive selection of this menu item by the user. Note that the “Checked” and “Unchecked” status is visible in the form of a “tick/check” symbol against the menu item when the menu GUI is open.

[code] debug.Checked = Not debug.Checked
If debug.Checked = True Then
MsgBox(“Debug On”)
Else
MsgBox(“Debug Off”)
End If

Return True[/code]
The above code compiles and executes on Windows 7, Xojo 2013r2 without any errors.