1. ATK Gimmy Susan
  2. PowerBuilder
  3. Tuesday, 28 April 2020 16:47 PM UTC

Good morning comunity

I need help with Ribbons.
I swear, I looked at the sample application 'Sales application demo', but I didn't find what I need and I don't get it on my own.
How can I add an 4th items to the tabbutton Azienda one item by code? (see image: add to <Menu> )
I found how to add a tabbutton, but not a single item.

Thanks in advance

 

 

Accepted Answer
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Tuesday, 28 April 2020 19:09 PM UTC
  2. PowerBuilder
  3. # Permalink

< Resolved >

integer li_rc
PowerObject po
RibbontabButtonItem item
RibbonMenu menu

li_rc = rbb_1.GetItemByTag( 'Azienda-Dipartimento', po )
IF li_rc < 0 THEN Return
item = po
li_rc = item.getmenu( menu)
li_rc = menu.Insertitemlast( '4th Item', 'Custom017a!', 'ue_someevent')
li_rc = item.setmenu( menu)
li_rc = rbb_1.settabbutton( item.itemhandle, item )

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 28 April 2020 20:17 PM UTC
Thanks for posting the solution!
  1. Helpful
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Tuesday, 28 April 2020 17:53 PM UTC
  2. PowerBuilder
  3. # 1

For future reference, if you want help with code, please post the code, not a picture of it.

 

Assume I have a ribbon bar with a drop down large button as follows:

        <Panel Text="Default Command" Tag="Default Command">
          <LargeButton Tag="DefaultCommandDemo" PictureName="ControlDropDownListBox!" Text="Demo" DefaultCommand="false" PowerTipText="Default Command Demo" PowerTipDescription="Demonstrates how the Default Command option makes a drop down button">
            <Menu>
              <Item Text="Item 1" PictureName="Custom001a!" Clicked="ue_defaultcommand1">
              </Item>
              <Item Text="Item 2" PictureName="Custom002a!" Clicked="ue_defaultcommand2">
              </Item>
              <Item Text="Item 3" PictureName="Custom003a!" Clicked="ue_defaultcommand3">
              </Item>
            </Menu>
          </LargeButton>
        </Panel>

 

Then I can add a fourth item by accessing the large button through it's tag value, grabbing the menu off of that and adding an item.

integer li_rc
PowerObject po
RibbonLargeButtonItem item
RibbonMenu menu

li_rc = rbb_1.GetItemByTag( 'DefaultCommandDemo', po )
IF li_rc < 0 THEN Return
item = po
li_rc = item.getmenu( menu)
li_rc = menu.Insertitemlast( '4th Item', 'Custom017a!', 'ue_someevent')
li_rc = item.setmenu( menu)
li_rc = rbb_1.setlargebutton( item.itemhandle, item )

 

The part that is going to throw most long term PowerBuilder developers is that inserting the item on the menu isn't going to make it appear in the toolbar.  What we're getting from the Get methods on the toolbar isn't a *reference* to an item, it's a *copy* of it.  Once you make your changes you need to use the Set methods to apply the changes back to the ribbonbar.

 

 

 

 

Comment
There are no comments made yet.
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Tuesday, 28 April 2020 18:27 PM UTC
  2. PowerBuilder
  3. # 2

Hi Bruce.


Thanks for the reply and the advice.
You are right. Here is example.xml below

Returning to the problem.
I need a different thing.
I don't have a 'ribbon bar with a drop down large button', but a tabbutton.

If you look at my xlm you will see that there are 3 menu items and I have to add the fourth one

 

Thanks again for your time

 

Attachments (1)
Comment
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.