English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 28 January 2022, 16:01   #1
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
Can a menu shortcut not be an Amiga-R + Something?

I am using NewMenu. One of the fields allows me to set the nm_CommKey. As stated in the documentation when I set this I get a picture of the AmigaR key and the letter I configure. Everything works as expected .

However I cannot find anywhere in documentation how I could set a shortcut that is not the AmigaR key + <Letter>. For example, is there a way how I could get an image of the Ctrl key + <Letter> instead? (example; Ctrl + C, Ctrl + V, etc).

Is this possible?

By looking at the documentation I can see that one possible () option is by using a MenuItem ItemFill and try and get a result that is similar to the one provided by LayoutMenus and then inject this new item in the menu returned by the CreateMenu call.

However I was wondering if there is a more standard way how to achieve this..

Anyone has any ideas?

Last edited by Sim085; 28 January 2022 at 16:09.
Sim085 is offline  
Old 29 January 2022, 02:33   #2
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
Hmm, I cannot understand from where the Amiga-R image is coming from when using NewMenus.

I can see that the CreateMenus function returns a Menu which FirstItem is a MenuItem which ItemFill is an IntuiText. IntuiText documentation, however, says "Each of these three objects may be chained together with other members of the same type". I therefore thought maybe the Amiga-R key printed in the menu is some fancy font, but the IntuiText structure NextText is NULL.

Code:
struct NewMenu menu[] ={
        {  NM_TITLE,    “MyMenu”, 0,  0,  0,  0 },
    {     NM_ITEM,    “MyMenuItem”, "A",0,  0,  0 },
}
struct Menu *strip = CreateMenus(menu, TAG_END);
struct MenuItem *mi = strip->FirstItem;
struct IntuiText *t = ((struct IntuiText *)mi->ItemFill);
// Prints MyMenuItem.
printf("%s\n", t->IText);
// But there are no other elements!
printf("Is Null? %d\n", t->NextText == NULL);
Is the Amiga-R key image being drawn by the LayoutMenus? If yes how does it do this?

Quote:
Originally Posted by Sim085 View Post
By looking at the documentation I can see that one possible () option is by using a MenuItem ItemFill and try and get a result that is similar to the one provided by LayoutMenus and then inject this new item in the menu returned by the CreateMenu call.

Last edited by Sim085; 29 January 2022 at 09:30.
Sim085 is offline  
Old 29 January 2022, 09:32   #3
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
To understand from where the Amiga-R image is coming from I built a menu the old way (using the Menu and MenuItem structures). I can see the Amiga-R image shows up as soon as the COMMSEQ flag is used in the MenuItem. So my original assumption that this was an Image pointed to from the MenuItem was wrong. From the code I have written it would seem this is done by the SetMenuStrip call.

So while I still wonder if there is some standard way how to get a different key image next to a menu item.

I wonder, if for example someone wants to draw a smiley next to a menu item how would that someone go about doing that?
Sim085 is offline  
Old 29 January 2022, 10:28   #4
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,987
You can allocate a second IntuiText and link it to the one created by CreateMenus. Leave COMMSEQ off.

LayoutMenus apparently has support for this already as it moves the second text to the right edge of the menu automatically.
thomas is offline  
Old 29 January 2022, 18:48   #5
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
Yeyyy

Can confirm that works.

It is not as beautiful as the Amiga Key image but it works

Quote:
Originally Posted by thomas View Post
You can allocate a second IntuiText and link it to the one created by CreateMenus. Leave COMMSEQ off.

LayoutMenus apparently has support for this already as it moves the second text to the right edge of the menu automatically.

Last edited by Sim085; 29 January 2022 at 20:21.
Sim085 is offline  
Old 31 January 2022, 02:22   #6
Warty
Registered User
 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 301
Maybe custom font with your preferred image(s), then use that font in the second intuiText?

Will the keyboard shortcut detection work though, for something other than Amiga key?
Warty is offline  
Old 31 January 2022, 22:54   #7
Sim085
Registered User
 
Join Date: Apr 2009
Location: N/A
Posts: 962
No, for the menu system it is just something cosmetic. I would need to add extra code to detect when the shortcut in question is pressed. In my case I am going to use this only for the exit menu option linking it to Esc instead of Amiga+Q.

Quote:
Originally Posted by Warty View Post
Will the keyboard shortcut detection work though, for something other than Amiga key?
Sim085 is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Custom Image for Amiga A Shortcut Key in Menus Warty Coders. C/C++ 1 14 July 2021 10:18
Shortcut keys for Amiga Forever player Axwind support.Amiga Forever 1 20 December 2018 21:15
Amiga - Windows 8 Start Menu twenty90seven New to Emulation or Amiga scene 9 24 May 2013 13:46
Amiga animated menu for emulator twenty90seven New to Emulation or Amiga scene 6 13 June 2012 15:07
Need opinions on amiga menu ? synchro Amiga scene 1 14 September 2009 13:11

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:15.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.45084 seconds with 13 queries