Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
172 user(s) are online (105 user(s) are browsing Forums)

Members: 0
Guests: 172

more...

Headlines

 
  Register To Post  

[Solved] Updating newmenu
Supreme Council
Supreme Council


See User information
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
Go to top
Re: Updating newmenu
Just can't stay away
Just can't stay away


See User information
@orgin

Why not use OnMenu()/OffMenu()?

I use these functions in AmiSoundED.

Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top
Re: Updating newmenu
Amigans Defender
Amigans Defender


See User information
@orgin

FULLMENUNUM(menu,menuitem,subitem)

From memory...

Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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_NEWOM_SETOM_UPDATE)


How does one invoke OM_UPDATE on a window?

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Updating newmenu
Amigans Defender
Amigans Defender


See User information
@orgin

RethinkLayout()? Might be a bit overkill.

Why do you need to scan the entire menu tree?

Chris

Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top
Re: Updating newmenu
Just can't stay away
Just can't stay away


See User information
@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().

Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top
Re: Updating newmenu
Amigans Defender
Amigans Defender


See User information
@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.

Go to top
Re: Updating newmenu
Supreme Council
Supreme Council


See User information
@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->WinObjWINDOW_NewMenuMenuTAG_DONE);

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Updating newmenu
Just can't stay away
Just can't stay away


See User information
@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);

Go to top
Re: [Solved] Updating newmenu
Just can't stay away
Just can't stay away


See User information
@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
Go to top
Re: [Solved] Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top
Re: [Solved] Updating newmenu
Just can't stay away
Just can't stay away


See User information
@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
Go to top
Re: [Solved] Updating newmenu
Supreme Council
Supreme Council


See User information
@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
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project