Intuition Menu Class

This forum is for general developer support questions.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Post by mritter0 »

The autodoc is lacking some very basic information/examples: how to disabled an item, check an item, etc.

Code: Select all

IIntuition->SetAttrs(MenuStripObj,
	MA_ID,				MEN_HELP_MENU_ABOUT,
	MA_Disabled,			TRUE,
TAG_END);
Would be super easy and nice. Does not work, disabled entire menu.

Code: Select all

Object *MenuStripObj;
struct mpFIndID *item;

item=(Object *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_HELP_MENU_ABOUT);
IIntuition->SetAttrs(item,
	MA_Disabled,				TRUE,
TAG_END);
That gives me "assignment from incompatible pointer type" warning on IDoMethod() line. What is correct way?

/////////////////////////////////////////////

I would like to see more "advanced" shortcut keys. Not just one letter and the Amiga symbol. Multi-qualifier hotkeys. Imagine a web browser menu:
......
Reload F5
Print A P (Amiga P)
Print... Ctrl+P (open a requester)
Next tab Ctrl+Tab
Previous tab Shift+Ctrl+Tab

The non-Amiga key shortcuts don't need to have a WMHI_MENUPICK (would be nice), make programmer look at RAWKEY, but just knowing what the shortcut keys are would be nice.

////////////////////////////////////////////////

I was hoping for a menu bar like Windows instead of a right-click traditional style menu. This would free up right-click for context menus in an easier to handle way.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Post by mritter0 »

item=(struct mpFindID *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);

not

item=(Object *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);
Workbench Explorer - A better way to browse drawers
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: Intuition Menu Class

Post by chris »

mritter0 wrote:I would like to see more "advanced" shortcut keys. Not just one letter and the Amiga symbol. Multi-qualifier hotkeys. Imagine a web browser menu:
......
Reload F5
Print A P (Amiga P)
Print... Ctrl+P (open a requester)
Next tab Ctrl+Tab
Previous tab Shift+Ctrl+Tab

The non-Amiga key shortcuts don't need to have a WMHI_MENUPICK (would be nice), make programmer look at RAWKEY, but just knowing what the shortcut keys are would be nice.
Already supported (haven't tested myself, but the docs say so).
mritter0 wrote: I was hoping for a menu bar like Windows instead of a right-click traditional style menu. This would free up right-click for context menus in an easier to handle way.
God no.

Context menus work fine; you get the main menu bar if you aren't over a contextual area. I don't see a problem with this - if you want to be sure you're not over a contextual area, move the pointer up to the screen title bar first - that's no different to what you'd need to do if the main menu bar was left-clickable.
User avatar
gazelle
Posts: 102
Joined: Sun Mar 04, 2012 12:49 pm
Location: Frohnleiten, Austria

Re: Intuition Menu Class

Post by gazelle »

mritter0 wrote:item=(struct mpFindID *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);

not

item=(Object *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);
That looks wrong, more like:

Code: Select all

    Object *MenuStripObj, *item;

    item=(Object *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_HELP_MENU_ABOUT);
    IIntuition->SetAttrs(item,
       MA_Disabled,            TRUE,
    TAG_END);
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Post by mritter0 »

Updated code examples to Gazelle's post. (struct mpFindID -> Object *).

With my example, I can't add an item to the first menu:

Code: Select all

	if (!(MenuStripObj=IIntuition->NewObject(NULL,"menuclass",MA_Type,T_ROOT,TAG_END)))
		return(FALSE);

	if (!DoNewMenu(MenuStripObj,
		MA_ErrorCode, &error,
		MA_ErrorTagItem, &error_ti,
		MA_FreeImage, FALSE,
		MA_EvenSize, TRUE,

		NM_Menu, SAK_LocaleString(MSG_PROJECT_MENU_PROJECT),
				MA_ID, MEN_PROJECT_MENU,
			NM_Item, SAK_LocaleString(MSG_PROJECT_MENU_ICONIFY),
				MA_ID, MEN_ICONIFY,
				MA_Key, "H",
			NM_Item, ML_SEPARATOR,
			NM_Item, SAK_LocaleString(MSG_PROJECT_MENU_QUIT),
				MA_ID, MEN_QUIT,
				MA_Key, "Q",
			NM_Item, SAK_LocaleString(MSG_PROJECT_MENU_QUIT_ALL),
				MA_ID, MEN_QUIT_ALL,
........
I can add items to the first menu's items (new item will a sub item), I can add a new item to the second NM_Menu just fine.

Code: Select all

		Object *AddItem;

		AddItem=MItem("New item added"), MA_ID, 6000, MEnd;

		SAK_AddMenuItem(MenuStripObj,MEN_PROJECT_MENU,AddItem);
Is there something special about it? The ID would be 0 in the enum

Code: Select all

enum
{
	MEN_PROJECT_MENU,
		MEN_ICONIFY,

		MEN_QUIT,
		MEN_QUIT_ALL,
........
//////////////////////////////////////////////////

Loving the longer text for short cut keys!
Workbench Explorer - A better way to browse drawers
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

Re: Intuition Menu Class

Post by chris »

mritter0 wrote: Is there something special about it? The ID would be 0 in the enum
That's likely your problem - 0 is invalid. You need to start at 1.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Post by mritter0 »

In the example in my previous post, MA_Hidden,TRUE, does not work; it displays the item. I believe it is just that type of menu creation.
Workbench Explorer - A better way to browse drawers
User avatar
gazelle
Posts: 102
Joined: Sun Mar 04, 2012 12:49 pm
Location: Frohnleiten, Austria

Re: Intuition Menu Class

Post by gazelle »

There is an example source of the new menu class in "SDK:Examples/GUI/MenuClass" which also uses the MA_Hidden tag.

I didn't try it out myself but maybe you'll see something.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Intuition Menu Class

Post by xenic »

mritter0 wrote:item=(struct mpFindID *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);

not

item=(Object *)IIntuition->IDoMethod(MenuStripObj,MM_FINDID,0,MEN_GO_BACK);
It does seem to me that object oriented programming defeats the type defining in the C language and strict type checking by a C compiler like GCC. It gets really tiresome to have to add type casting to half the function calls in a program to get rid of warnings.

I also noticed that IIntuition->SetMenuStrip() produces a warning for a menu class argument:
warning: passing argument 3 of 'IIntuition->SetMenuStrip' from incompatible pointer type

Maybe a seperate function (like SetMenuStripObj) with correct argument types would have been more in keeping with C language type identification.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Intuition Menu Class

Post by salass00 »

xenic wrote: Maybe a seperate function (like SetMenuStripObj) with correct argument types would have been more in keeping with C language type identification.
There already is one, it's called SetWindowAttrs() (with WA_MenuStrip tag). No need to bother with legacy functions like SetMenuStrip().
Post Reply