On Sun, Nov 18, 2012 at 3:05 PM, Art Heimsoth <artst...@artheimsoth.com>wrote:

> What do I use for the position number of a separator?
>

5 would be right in this case.  But, ... if you use position, you can only
use position within each submenu.  So in your case you first need to get
the file submenu and then use the position on that menu.


> I have defined the
> menu as:
> MYMENU_MENU MENU
> {
>     POPUP "&File"
>     {
>         MENUITEM "&Open", MENU_FILEOPEN
>         MENUITEM "&New", MENU_FILENEW
>         MENUITEM "&Save", MENU_FILESAVE
>         MENUITEM "&Saveas", MENU_FILESAVEAS
>         MENUITEM SEPARATOR
>         MENUITEM "Recent", MENU_FILELAST1
>       ....
>
> Trying to use
>       menubar=.ScriptMenuBar~new("Fescue.rc", MYMENU_MENU, , , .true, self)
>
>       /* disable/remove/setup initial MenuBar File items        */
>       menubar~disable(MENU_FILESAVE)
>       menubar~disable(MENU_FILESAVEAS)
>       menubar~removeSeparator(5,.true)
>       menubar~removeItem(MENU_FILELAST1)
>
>

In the above, the 5 would have to be the 5th item in the *menu bar*, which
doesn't exist.

You first need to get the File submenu, and then remove the separator.
 Which you could do like this:

-- Get the first submenu by position:
filePopup = menubar~getPopup(1, .true)

filePopup~removeSeparator(5, .true)

The other menubar~xx methods work because you are using the resource ID of
the menu items.  When you use resource IDs, you can work with any menu item
in the entire menu, because the resource ID uniquely specifies any menu
item.

When you use position IDs, you can not uniquely specify any item.  Say you
had a File submenu at position 1 and an Edit submenu at postion 2.  Then
you could have a menu item at position 1 in the File submenu and a menu
item at position 1 in the Edit submenu.  To use position IDs in this case,
you first need to get the submenu the item is in and then specify position
1.


> The other items on the menu are disabled/removed, but the separator
> remains.
> Also, if this would be a popup other than the first, as in this case, how
> would
> the numbering then be defined/resolved?
>

The reason things work as they do here, is not because the File submenu is
the first subumenu.  It works because you are using resource IDs to specify
the items.

The best thing to do, is to try and always assign a resource ID to each
menu item and then use the resource ID to specify items.  This will always
work.  However, many, if not most, resource editors don't allow you to
specify a resource ID for separators.  (The operating system *does* allow
it.)

So, for a popup other than the first, let's use my example of a File menu
and an Edit menu.  If you had a separator in each popup at position 3, that
you wanted to remove them both, you could do this:

-- Get the first submenu by position:
filePopup = menubar~getPopup(1, .true)

filePopup~removeSeparator(3, .true)

-- Get the second submenu by position:
editPopup = menubar~getPopup(2, .true)

editPopup~removeSeparator(3, .true)

The above should work.

An interesting point is that the operating system allows assigning resource
IDs to those top-level popup menus in the menu bar.  So, you should be able
to get those popup menus using a resource ID.  But, here again, most
resource editors don't give you the option of assigning an ID.

So this could have been:

MYMENU_MENU MENUEX
{
    POPUP "&File" IDM_FILE_POPUP
    {
        MENUITEM "&Open", MENU_FILEOPEN
        MENUITEM "&New", MENU_FILENEW
        MENUITEM "&Save", MENU_FILESAVE
        MENUITEM "&Saveas", MENU_FILESAVEAS
        MENUITEM SEPARATOR
        MENUITEM "Recent", MENU_FILELAST1
      ....

where IDM_FILE_POPUP would be a symbolic ID of say, 150.  With the extended
menu format, separators can be assigned IDs also and you could remove it by
ID without worrying about the position thing.

--
Mark Miesfeld
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to