1. Philip Troise
  2. PowerBuilder
  3. Tuesday, 2 March 2021 10:42 AM UTC

2019 R3     IDE and Runtimw 2556 built on 9/9/2020

 

So what is the winning combinations of commands that will loop through the submenu’s in the master menu?

Could it be that there is no way and I have to await enhanced features?

 

 

Below is the beginning of loop through categories and panels.

PowerObject lpo_object, lpo_object2

int li_Return, i, j, li_num_of_categories, li_master_items_count, li_submenu_master_items_count

Integer li_subcount, li_index, li_index2

 

 

RibbonLargeButtonItem lr_LargeButton

RibbonSmallButtonItem lr_SmallButton

RibbonMenuItem lr_MenuItem

RibbonCategoryItem lr_category

RibbonPanelItem lr_panel

RibbonMenu lr_Menu

RibbonApplicationButtonItem buttonitem

RibbonApplicationMenu appmenu

 

 

 

       FOR j = 1 to ll_panel_count

               li_Return = rbb_main.GetChildItemByIndex(lr_category.itemhandle, j, lr_panel)

                ll_child_count = rbb_main.GetChildItemCount(lr_panel.itemhandle)

                FOR i = 1 to ll_child_count

                       li_Return = rbb_main.GetChildItemByIndex(lr_panel.itemhandle,i, lpo_Object)

                       //LargeButton Visible and enable control

                       lr_LargeButton = lpo_Object

                        DO

                               IF lr_LargeButton.text = "Add Reservation" OR lr_LargeButton.text = "Dash Board" THEN

                                        IF ls_s1=TRUE THEN

                                                 lr_LargeButton.Enabled = TRUE

                                                                                               

                                                 Set 2nd MASTER ITEM enabled=TRUE                               

                                                 li_index = 2     // 2 master menu                                                

                                                 //Gets a copy of MenuItem from the copy of ApplicationMenu

                                                  li_Return = appmenu.GetMasterItem(li_index, lr_MenuItem )

                                                  //Set master menu to enabled=TRUE

                                                  lr_MenuItem.Enabled=TRUE

                               

       non of the commands work below on the submenu's . I completely do not understand if or how it should work

                           li_submenu_master_items_count = appmenu.GetRecentItemCount()

                           li_Return = appmenu.SetRecentItem(li_index2, lr_MenuItem)

                            li_Return = appmenu.GetRecentItem (li_index2, lr_MenuItem)

 

 

//SAVE ALL CHANGES BACK

//For the change to take effect, sets the copy of MenuItem back to the copy of ApplicationMenu
li_Return = appmenu.SetMasterItem( li_index, lr_MenuItem )
//Then sets the copy of ApplicationMenu back to the copy of ApplicationButton
li_Return = buttonitem.Setmenu( appmenu )
//Finally sets the copy of ApplicationButton back to the RibbonBar control
li_Return = rbb_main.SetApplicationbutton( buttonitem )

  

 // ApplicationButton master Items

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<RibbonBar BuiltinTheme="0" Font="FaceName:Tacoma; TextSize:10">
  <RibbonItems>

    <ApplicationButton Text="Application" Enabled="true" Tag="RibbonBar Demo" Visible="true">
      <ApplicationMenu>
        <Master>
     
         <Item Text="Front Desk" PictureName="" Checked="false" Enabled="true" Tag="" Type="0" Visible="true" Clicked="">
             <Item Text="Unit-Chart" PictureName="ChartBig!" Checked="false"  Enabled="false" Shortcut="" Tag="Unit-Chart" Type="0" Visible="true" Clicked="ue_menuitemclicked"></Item>
             <Item Text="Arrivals" PictureName="CustomerBig!" Checked="false" Enabled="false" Shortcut="" Tag="Arrivals" Type="0" Visible="true" Clicked="ue_menuitemclicked"></Item>
             <Item Text="Departures" PictureName="AccountBig!" Checked="false"  Enabled="false" Shortcut="" Tag="Departures" Type="0" Visible="true" Clicked="ue_menuitemclicked"></Item>
        <Item Text="Arrivals + Departures" PictureName="TeamworkBig!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0"  Visible="true" Clicked="ue_menuitemclicked"></Item>
        <Item Text="Dash Board" PictureName="AlignBig!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_menuitemclicked"></Item>
             <Item Text="Add Reservation" PictureName="AddBig!" Checked="false" Enabled="false" Shortcut="R" Tag="Add Reservation" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
                <Item Text="Update Reservation" PictureName="TabHeaderSelectedBig!" Checked="false" Enabled="false" Shortcut="F2" Tag="Update and Delete Reservation" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
                <Item Text="Guest Stay Overs" PictureName="Cascade1!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
                <Item Text="Group" PictureName="TeamworkBig!" Checked="false" Enabled="false" Shortcut="" Tag="" Type="0"  Visible="true" Clicked="ue_mastermenuclicked"></Item>
                <Item Text="Walk-In" PictureName="CustomerBig!" Checked="false"  Enabled="false" Shortcut="" Tag="Walk-In" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
             <Item Text="Check-In Guests" PictureName="CustomerBig!" Checked="false"  Enabled="false" Shortcut="" Tag="Check-In" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
            <Item Text="Check-Out" PictureName="AccountBig!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
            <Item Text="Open Folios" PictureName="Cascade1!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
              <Item Text="Folio History" PictureName="CopyBig!" Checked="false"  Enabled="false" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
              <Item Text="Balance Due" PictureName="AccountingNumberFormatBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
             <Item Text="Deposit" PictureName="CurrencyBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
             <Item Text="Guest Profiles" PictureName="EmployeeBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
             <Item Text="Service Out" PictureName="PropertiesBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
              <Item Text="Point of Sale" PictureName="OptionsBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
              <Item Text="User LogOn" PictureName="AccountBig!" Checked="false"  Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>
              <Item Text="Remote Support" PictureName="TelephoneBig!" Checked="false" Enabled="true" Shortcut="" Tag="" Type="0" Visible="true" Clicked="ue_mastermenuclicked"></Item>                    
           </Item>    

Philip Troise Accepted Answer Pending Moderation
  1. Wednesday, 3 March 2021 14:38 PM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Thanks you. I works.    !!!!!!

Comment
Which one is the correct answer? Please make the accepted answer.
  1. Armeen Mazda @Appeon
  2. Wednesday, 3 March 2021 14:56 PM UTC
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 3 March 2021 12:42 PM UTC
  2. PowerBuilder
  3. # 2
0
Votes
Undo

Hi Philip,

The Recent... functions are for the special recent menu items.

To loop through the normal application menu you have to use GetMasterItem... functions.

Use this to start:

RibbonApplicationButtonItem application_button
RibbonApplicationMenu ApplicationMenu
RibbonMenuItem Item
long ll_i, ll_c, ll_j, ll_c2

rbb_menu.GetApplicationButton (application_button)
application_button.GetMenu (ApplicationMenu)

ll_c = ApplicationMenu.GetMasterItemCount ()

FOR ll_i = 1 TO ll_c
ApplicationMenu.GetMasterItem (ll_i, Item)
MessageBox ("Item " + string (ll_i), item.text)
ll_c2 = ApplicationMenu.GetMasterItemCount(ll_i)
FOR ll_j = 1 TO ll_c2
ApplicationMenu.GetMasterItem (ll_i, ll_j, Item)
MessageBox ("SubItem " + string (ll_j), item.text)
NEXT
NEXT
Comment
There are no comments made yet.
Philip Troise Accepted Answer Pending Moderation
  1. Tuesday, 2 March 2021 21:24 PM UTC
  2. PowerBuilder
  3. # 3
0
Votes
Undo

Thanks for clarifying that I could not use the getitembytag method

 

I tried to use the tag method after not being able to get your recommended method "GetItem Syntax 4, GetMasterItem, and GetRecentItem function"

Comment
There are no comments made yet.
Philip Troise Accepted Answer Pending Moderation
  1. Tuesday, 2 March 2021 17:52 PM UTC
  2. PowerBuilder
  3. # 4
0
Votes
Undo

How do a Loop through submenu's items for each master item

 

 

Integer li_subcount, li_index, li_index2

RibbonLargeButtonItem lr_LargeButton
RibbonSmallButtonItem lr_SmallButton
RibbonMenuItem lr_MenuItem
RibbonCategoryItem lr_category
RibbonPanelItem lr_panel
RibbonMenu lr_Menu


RibbonApplicationButtonItem buttonitem
RibbonApplicationMenu appmenu

 

//Below will get the second master item and make Enabled=TRUE

li_index = 2
li_Return = appmenu.GetMasterItem(li_index, lr_MenuItem )
lr_MenuItem.Enabled=TRUE

 

//My attempt to loop through sub master item's of each master item

//All the below fail.

//How do a Loop through submenu's items for each master item

li_Return = appmenu.SetRecentItem(li_index, lr_MenuItem)

li_Return = appmenu.GetRecentItem (li_index, lr_MenuItem)

li_submenu_master_items_count = appmenu.GetRecentItemCount()

 

 







//For the change to take effect, sets the copy of MenuItem back to the copy of ApplicationMenu
li_Return = appmenu.SetMasterItem( li_index, lr_MenuItem )
//Then sets the copy of ApplicationMenu back to the copy of ApplicationButton
li_Return = buttonitem.Setmenu( appmenu )
//Finally sets the copy of ApplicationButton back to the RibbonBar control
li_Return = rbb_main.SetApplicationbutton( buttonitem )

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 2 March 2021 11:46 AM UTC
  2. PowerBuilder
  3. # 5
0
Votes
Undo

Hi Philip,

In usage notes of function GetItemByTag in the help you can find this information:

The GetItemByTag and GetItem functions can be used to get items including ApplicationButton, TabButton, Category, Panel, Group, LargeButton, SmallButton, CheckBox, and ComboBox; but cannot get RibbonMenuItem, RibbonApplicationMenu, and RibbonMenu. To get RibbonMenuItem, you can use the GetItem Syntax 4, GetMasterItem, and GetRecentItem functions. To get RibbonApplicationMenu and RibbonMenu, you can use the GetMenu and GetMenuByButtonHandle functions.

 

To find the item you want you have to loop through the Master item.

 

HTH,

René

Comment
Its looping through the submenu’s and I able to change the enabled to false or true

But I can seem to save the changes to the submenu's.



The master item saves correctly but not the changes to the submenu item’s



Below I tried using SetRecentItem. Still not working



//li_master_items_count = 2

FOR li_index = 1 TO li_master_items_count

appmenu.GetMasterItem (li_index, lr_MenuItem)

//MessageBox ("Item " + string (li_index), lr_MenuItem.text)

lr_MenuItem.enabled=TRUE

li_Return = appmenu.SetMasterItem( li_index, lr_MenuItem )

li_submenu_master_items_count = appmenu.GetMasterItemCount(li_index)

FOR j = 1 TO li_submenu_master_items_count

appmenu.GetMasterItem (li_index, j, lr_MenuItem)

lr_MenuItem.enabled=TRUE

li_Return = appmenu.SetRecentItem( j, lr_MenuItem )

//MessageBox("SubItem " + string (j), lr_MenuItem.text)

NEXT

// li_Return = appmenu.SetMasterItem( li_index, lr_MenuItem )

NEXT



//li_index = 3

// working update application button logic

//For the change to take effect, sets the copy of MenuItem back to the copy of ApplicationMenu

li_Return = appmenu.SetMasterItem( li_index, lr_MenuItem )

//Then sets the copy of ApplicationMenu back to the copy of ApplicationButton

li_Return = buttonitem.Setmenu( appmenu )

//Finally sets the copy of ApplicationButton back to the RibbonBar control

li_Return = rbb_main.SetApplicationbutton( buttonitem )

  1. Philip Troise
  2. Wednesday, 3 March 2021 19:47 PM UTC
I think you want to use SetMasterItem and not SetRecentItem fpr the sub menu:

appmenu.SetMasterItem( li_index, j, lr_MenuItem )



  1. René Ullrich
  2. Thursday, 4 March 2021 07:09 AM UTC
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.