Who's Online
125 user(s) are online (
112 user(s) are browsing
Forums )
Members: 1
Guests: 124
LiveForIt ,
more...
Topic options
View mode
Newest First
[Solved] Updating newmenu
Posted on:
2009/5/20 10:29
#1
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
Is there something like ResetMenuStrip() for newmenues ? I need to enable/disable menu entries on the fly.
Edited by orgin on 2009/5/20 14:33:00
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 11:25
#2
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@orgin Why not use OnMenu()/OffMenu()? I use these functions in AmiSoundED.
Re: Updating newmenu
Posted on:
2009/5/20 12:48
#3
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@salass00 Leads to a hard crash. What exactly am I supposed to put in the "menunumber" field?
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 12:52
#4
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: Yesterday 20:40
From England
Group:
Registered Users Moderators
@orgin FULLMENUNUM(menu,menuitem,subitem) From memory...
Re: Updating newmenu
Posted on:
2009/5/20 13:13
#5
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@Chris Hmmf I see, extremely annoying, means I have to scan the entire menu tree several times to find all the items I need. Is there really no better way to do this? In comparison it seems easier to just iconify and deiconify the window. (the menus are remade when you do that)
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 13:19
#6
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@orgin
WINDOW_NewMenu ( struct NewMenu *) Let window .class create and layout the menus for you . This is useful for iconification and screenchanges . Remember that the NewMenu array must be persistent because it will be referenced every time the window opens . Defaults to NULL . Applicability is ( OM_NEW , OM_SET , OM_UPDATE )
How does one invoke OM_UPDATE on a window?
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 13:52
#7
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: Yesterday 20:40
From England
Group:
Registered Users Moderators
@orgin RethinkLayout()? Might be a bit overkill. Why do you need to scan the entire menu tree? Chris
Re: Updating newmenu
Posted on:
2009/5/20 14:03
#8
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@Chris The newmenu array is just a flat array. I do not want to index it directly since I change it a lot. Which means that I scan the array items for the correct userdata field to find the items I want to enable/disable. Using the mentioned define/macro means that I need to know which (sub)menu the item is in as well, which can change. Which basically means that I have to make my own tree structure out of the menu array so I can find which parent a certain item has. WM_RETHINK had no effect. RethinkLayout is intended for the gadget layout, not menu.
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 14:05
#9
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@orgin You could obtain a pointer to the menu strip using: Object *window_obj; struct Menu *menu; GetAttr(WINDOW_MenuStrip, window_obj, (uint32 *)&menu); and then ClearMenuStrip(), make your menu changes and ResetMenuStrip().
Re: Updating newmenu
Posted on:
2009/5/20 14:08
#10
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@salass00 Tried that, had no effect. I don't think that is related to newmenu but the old style menu.
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 14:25
#11
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: Yesterday 20:40
From England
Group:
Registered Users Moderators
@orgin MenuStrip is the old-style, but the GadTools functions convert from NewMenu to MenuStrip - Intuition only deals with MenuStrip. So if you grab the MenuStrip, update your NewMenu, you would then have to run it through the GadTools function (CreateMenu()?) to get the new MenuStrip, and re-apply it. Or you could just SetAttrs(WINDOW_NewMenu) and dispose the old one, ignoring MenuStrip entirely.
Re: Updating newmenu
Posted on:
2009/5/20 14:36
#12
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@Chris
Thanks, this solved it:
int32 i = 0 ; while( Menu [ i ]. nm_Type != NM_END ) { if(( ULONG ) Menu [ i ]. nm_UserData == MENU_COPYAS || ( ULONG ) Menu [ i ]. nm_UserData == MENU_MOVEAS ) { Menu [ i ]. nm_Flags = NM_ITEMDISABLED ; } i ++; } IIntuition -> SetAttrs ( inst -> WinObj , WINDOW_NewMenu , Menu , TAG_DONE );
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: Updating newmenu
Posted on:
2009/5/20 14:37
#13
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@orgin You are modifying the menu strip and not new menu, right? If it's the latter you need to use SetAttrs() with WINDOW_NewMenu tag: Object *window_obj; struct NewMenu *newmenu; SetAttrs(window_obj, WINDOW_NewMenu, NULL, TAG_END); /* make changes to newmenu structures */ SetAttrs(window_obj, WINDOW_NewMenu, newmenu, TAG_END);
Re: [Solved] Updating newmenu
Posted on:
2009/5/20 14:52
#14
Just can't stay away
Joined: 2007/2/23 13:49Last Login
: 11/16 0:49
From Finland, the land of Santa, sauna, sisu and salmiakki
Group:
Registered Users
@orgin
Quote:
I need to enable/disable menu entries on the fly. I'm using this:
struct NewMenu MainMenu[]=
{
{ NM_TITLE,"Project",0,0,0,0 },
{ NM_ITEM,"About...","?",0,0,0 },
{ NM_ITEM,"Iconify","I",0,0,0 },
{ NM_ITEM,"Quit","Q",0,0,0 },
{ NM_END,NULL,0,0,0,0 }
};
enum
{
PROJECT_MENU
};
enum
{
MENU_ABOUT,
MENU_ICONIFY,
MENU_QUIT
};
IIntuition->OffMenu(MyWindow,FULLMENUNUM(PROJECT_MENU,MENU_ICONIFY,NOSUB)); // Iconify
IIntuition->OnMenu(MyWindow,FULLMENUNUM(PROJECT_MENU,MENU_ICONIFY,NOSUB)); // Iconify
No need to refresh or reset anything at all.
Rock lobster bit me - so I'm here forever X1000 + AmigaOS 4.1 FE "Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Re: [Solved] Updating newmenu
Posted on:
2009/5/20 16:01
#15
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@TSK I have several menus and I do not want to hard code which one an entry is in. So to find what menu an item is in means keeping track of the menus. Which is overkill just to refresh the menu. (I tried to explain all of this above but I guess it wasn't clear enough) But anyway, the issue is solved so unless it's not legal to do what I said earlier there's no need to find any other solution.
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Re: [Solved] Updating newmenu
Posted on:
2009/5/20 18:00
#16
Just can't stay away
Joined: 2007/2/23 13:49Last Login
: 11/16 0:49
From Finland, the land of Santa, sauna, sisu and salmiakki
Group:
Registered Users
@orgin
Quote:
Why not use OnMenu()/OffMenu()? Quote:
Leads to a hard crash. What exactly am I supposed to put in the "menunumber" field? You said OnMenu and OffMenu were crashing so I showed an example only. (Looks like Chris answered already to you.)
Quote:
I have several menus and I do not want to hard code which one an entry is in. So, do you mean you're adding and removing menu items on the fly instead of just disabling and enabling them ???
Rock lobster bit me - so I'm here forever X1000 + AmigaOS 4.1 FE "Anyone can build a fast CPU. The trick is to build a fast system." - Seymour Cray
Re: [Solved] Updating newmenu
Posted on:
2009/5/20 18:16
#17
Supreme Council
Joined: 2006/11/16 19:25Last Login
: Yesterday 16:40
From Sweden
Group:
Webmasters Moderators Staff members Staff members Moderators Staff members Staff members
@TSK "So, do you mean you're adding and removing menu items on the fly instead of just disabling and enabling them ???" Nope.
Vacca foeda. Sum, ergo edo Mr Bobo Cornwater
Currently Active Users Viewing This Thread:
3
(
0 members
and 3 Anonymous Users
)