Intuition Menu Class

This forum is for general developer support questions.

Re: Intuition Menu Class

Postby mritter0 » Thu Sep 10, 2015 5:35 am

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: 212
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Postby mritter0 » Thu Sep 10, 2015 5:42 am

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
User avatar
mritter0
 
Posts: 212
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Postby chris » Thu Sep 10, 2015 11:55 am

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.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition Menu Class

Postby gazelle » Fri Sep 11, 2015 12:01 am

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
gazelle
 
Posts: 102
Joined: Sun Mar 04, 2012 1:49 pm
Location: Frohnleiten, Austria

Re: Intuition Menu Class

Postby mritter0 » Fri Sep 11, 2015 12:18 am

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
User avatar
mritter0
 
Posts: 212
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Postby chris » Fri Sep 11, 2015 12:21 am

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.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

Re: Intuition Menu Class

Postby mritter0 » Fri Sep 11, 2015 4:11 am

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
mritter0
 
Posts: 212
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: Intuition Menu Class

Postby gazelle » Fri Sep 11, 2015 9:36 am

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.
User avatar
gazelle
 
Posts: 102
Joined: Sun Mar 04, 2012 1:49 pm
Location: Frohnleiten, Austria

Re: Intuition Menu Class

Postby xenic » Fri Sep 11, 2015 7:46 pm

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
xenic
 
Posts: 1149
Joined: Sun Jun 19, 2011 1:06 am

Re: Intuition Menu Class

Postby salass00 » Fri Sep 11, 2015 8:11 pm

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().
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 507
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

PreviousNext

Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 4 guests