Hide/Show Igor Menus Question

In case anyone else is trying this.

HideIgorMenus without anything else hides everything Igor-related except the main Igor64 menu. However, in this remaining menu, About Igor64 and Quit Igor64 become disabled.

How does one recover this menu? ShowIgorMenus "Igor64" or "IgorPro" or ... return an error that these are not standard Igor Pro menu names.

Version 8.x

While Igor 6 on the Mac did not behave this way, it did on Windows because Windows doesn't have an application menu.

With the Qt framework, the Quit menu always believes it is in the File menu, and HideIgorMenus hides the File menu.

Same for the About Igor item, which believes it is in the Help menu.

This behavior on Macintosh is supposed to be Qt's Mac-friendly way to handle a cross-platform implementation with the menus configured the same on both platforms, but they appear in different menus depending on the platform.

Overriding this behavior would require a patch to the Qt source code (for Igor 9.01 or later), and could only be done with great effort.

Note that on Windows, the Exit menu item is in the File menu anyway, so HideIgorMenus naturally disappears the menu item needed to quit Igor. But Windows users know they can click the close box on an application frame to quit the program, so it is less of an issue there.

When someone hides the File menu the Quit menu is hidden or disabled on either platform, and quitting must be done through other means. Usually the programmer has a panel with a "Quit" button or user-defined menu definition that invokes the Quit command.

Typing ShowIgorMenus "File" on Igor's command line brings back the entire File menu and enables the application menu's "Quit Igor64" menu item.

Users can, of course, just type "quit" on the command line if the command window is visible.

It would be nice if a dynamic menu definition could know that the File menu is hidden and conditionally supply a non-hidden Quit menu, but I have not had success in coming up with a solution that works as a self-contained dynamic menu item function. DoIgorMenu/C doesn't report on menus, just items.

But using a global variable works:

Menu "Macros", dynamic
    ShowOrHideIgorMenusMenu(), /Q, ToggleIgorMenus()
End

Function/S ShowOrHideIgorMenusMenu()
    String menuItem = "Hide Igor Menus"
    Variable IgorMenusAreHidden = NumVarOrDefault("root:IgorMenusAreHidden",0)
    if( IgorMenusAreHidden )
        menuItem = "Show Igor Menus"
    endif
    return menuItem
End

Function ToggleIgorMenus()
    Variable IgorMenusAreHidden = NumVarOrDefault("root:IgorMenusAreHidden",0)
    if( IgorMenusAreHidden )
        ShowIgorMenus
    else
        HideIgorMenus
    endif
    Variable/G root:IgorMenusAreHidden = !IgorMenusAreHidden
End

Menu "File", dynamic
    PossibleQuitMenu(), /Q, Quit
End

Function/S PossibleQuitMenu()
    String menuItem="Quit Igor64/Q"
    Variable fileMenuIsHidden = NumVarOrDefault("root:IgorMenusAreHidden",0)
    if( !fileMenuIsHidden )
        menuItem="" // disappear the menu item; the regular one is fine
    endif
    return menuItem
End

 

Thanks Jim. I've been emailing also with John and AG (and Adam) about my end goal.

On macOS with IgorPro 8x, based on your feedback, this works with the noted problem.

Static Function make_AsDemo()
    HideIgorMenus
    SetIgorMenuMode "Help", "About Igor", EnableItem
    // --> DOES NOT WORK HERE --> SetIgorMenuMode "File", "Quit Igor64", EnableItem
    return 0
end

I've tried Igor in place of Igor64 to no avail. It seems, without the Quit menu active, the command-Q (macOS) also becomes deactivated.

If you have any insights what should be in place of "Quit Igor64" for the "File" menu, I will modify. Otherwise, perhaps the easiest is as you say that I should simply include a QUIT button appropriately placed on my demonstration packages.

You won't be able to enable the builtin About Igor or Quit Igor menus when their parent menus are hidden (which they are with a bare HideIgorMenus). Qt won't allow it.

You need to use my example to form replacement user-defined menu items that disappear when Igor menus are shown and exist when Igor menus are hidden.

My example should work on Igor 8.

OK. I got it to work as I want. I was sometimes able to have the About Igor64 option show up. I believe this happened when I would type control-ZERO to restart a new instance. Eventually I just went with your approach using a menu with a Quit option.

For anyone so inclined to want to limit the options for users to vary stuff with their package (e.g. make "demo" versions), this is the general approach that I have taken so far.

Menu "This Demo"
    "Quit This Demo", /Q, Quit_ThisDemo()
end

Function Quit_ThisDemo()
    Execute/Q/Z "Quit /N"
    return 0
end

Static Function AfterCompiledHook()
    // a function to initialize stuff
    initialize_Me()
    // function to hide menus and lock graphs + panels
    make_AsDemo()
    return 0
end

Static Function make_AsDemo()
    HideIgorMenus
    ModifyGraph/W=... UIControl=4095
    ModifyPanel/W=... fixedSize=1, noEdit=1
    return 0
end