Page 1 of 1
Menu with several windows
Posted: Thu Mar 15, 2018 7:07 pm
by plantenkennis
In my main window I have a menu that is visible at the top of my screen. When I create another window in my program I can set a menu for this window, which replaced the first menu. But when I close the second window, how do I get my first menu visible again.
Re: Menu with several windows
Posted: Wed Mar 21, 2018 11:06 am
by Antonio Linares
René,
You save each menu in a variable, like oMenu1, oMenu2, etc. then you do:
oMenuX:Activate()
Re: Menu with several windows
Posted: Fri Mar 23, 2018 2:09 pm
by plantenkennis
Hello Antonio,
This simple command does the trick. Thanks
Re: Menu with several windows
Posted: Tue Apr 03, 2018 9:08 pm
by plantenkennis
Hello Antonio,
I was playing around with the menu again, but can't get it to work. I can set a new menu with a new window or diolog, but nothing happens when I click on a menuitem. I have created a little sample.
Code: Select all
#include "FiveMac.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
BuildMenu()
DEFINE WINDOW oWnd TITLE "Hello world"
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Want to end ?" )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Files" && in menu this gives 'testmenu'
MENU
MENUITEM "New..."
MENUITEM "Open..." ACTION New_Window()
SEPARATOR
MENUITEM "Exit..." ACTION oWnd:End()
ENDMENU
MENUITEM "Help"
MENU
MENUITEM "Wiki..."
MENUITEM "About..." ACTION MsgAbout( "(C) FiveTech Software 2012", "FiveMac" )
ENDMENU
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function New_Window()
local oDlg, oMenuDlg
DEFINE DIALOG oDlg
BuildMenuDlg()
ACTIVATE DIALOG oDlg
return nil
//----------------------------------------------------------------------------//
function BuildMenuDlg()
local oMenuDlg
MENU oMenuDlg
MENUITEM 'Dialog'
MENU
MENUITEM "help" ACTION MsgAbout( "Do we see this", "Test" )
ENDMENU
MENUITEM 'Test me'
MENU
MENUITEM "Click on me!" ACTION MsgInfo('show me')
ENDMENU
ENDMENU
return oMenuDlg
Also the first MenuItem is always the name of the app, even if i write something different on that place.
Re: Menu with several windows
Posted: Tue Apr 10, 2018 2:05 pm
by mastintin
One solution ....
Code: Select all
#include "FiveMac.ch"
static oWnd
static MenuParent
//----------------------------------------------------------------------------//
function Main()
BuildMenu()
DEFINE WINDOW oWnd TITLE "Hello world"
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Want to end ?" )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
MENU MenuParent
MENUITEM "Files" && in menu this gives 'testmenu'
MENU
MENUITEM "New..."
MENUITEM "Open..." ACTION New_Window()
SEPARATOR
MENUITEM "Exit..." ACTION oWnd:End()
ENDMENU
MENUITEM "Help"
MENU
MENUITEM "Wiki..."
MENUITEM "About..." ACTION MsgAbout( "(C) FiveTech Software 2012", "FiveMac" )
ENDMENU
ENDMENU
return MenuParent
//----------------------------------------------------------------------------//
function New_Window()
local oDlg, oMenuDlg
DEFINE DIALOG oDlg
BuildMenuDlg()
ACTIVATE DIALOG oDlg ;
VALID ( MenuParent:activate(),.t. )
return nil
//----------------------------------------------------------------------------//
function BuildMenuDlg()
local oMenuDlg
MENU oMenuDlg
MENUITEM 'Dialog'
MENU
MENUITEM "help" ACTION MsgAbout( "Do we see this", "Test" )
ENDMENU
MENUITEM 'Test me'
MENU
MENUITEM "Click on me!" ACTION MsgInfo('show me')
ENDMENU
ENDMENU
return oMenuDlg
Re: Menu with several windows
Posted: Tue Apr 10, 2018 7:04 pm
by plantenkennis
Hello Mastintin,
Thank you for this sample, but it changes nothing to the problem I have. If you open the New window/dialog the oMenuDlg comes at the top, but nothing happens if you click one of the items (like 'help' or 'click on me'.
I think I will work with icons oon all my dialog windows to activate actions.
Re: Menu with several windows
Posted: Thu Apr 12, 2018 9:11 pm
by mastintin
I have reviewed the code of the menu class and made some changes so that you can switch between the menus you want only by activating them.
The Menus on Mac belong to the application and not to the windows, so it is up to the programmer to exchange them as needed.
You can also include images in them.
Soon it will be ready ...
Regards