Menu with several windows

Menu with several windows

Postby plantenkennis » Thu Mar 15, 2018 7:07 pm

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.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Menu with several windows

Postby Antonio Linares » Wed Mar 21, 2018 11:06 am

René,

You save each menu in a variable, like oMenu1, oMenu2, etc. then you do:

oMenuX:Activate()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Menu with several windows

Postby plantenkennis » Fri Mar 23, 2018 2:09 pm

Hello Antonio,

This simple command does the trick. Thanks
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Menu with several windows

Postby plantenkennis » Tue Apr 03, 2018 9:08 pm

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  Expand view

#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.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Menu with several windows

Postby mastintin » Tue Apr 10, 2018 2:05 pm

One solution ....

Code: Select all  Expand view


#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

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Menu with several windows

Postby plantenkennis » Tue Apr 10, 2018 7:04 pm

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.
Kind regards,

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Menu with several windows

Postby mastintin » Thu Apr 12, 2018 9:11 pm

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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 12 guests