Accessing the RibbonBar items in the hierarchy – PB Docs 2019

Accessing the RibbonBar items in the hierarchy

The RibbonBar control is a container. The RibbonBar control as
well as the item controls it contains have a hierarchical relationship.
The item controls cannot exist independently and must be placed on top
of the parent object; therefore, to get an item control, you need to
search from the top level (RibbonBar control), or to search by tag. The
control you get is a copy (not a reference), and after the copy is
modified, it needs to be set back to the parent object, and then to the
RibbonBar control, for the change to take effect.

To access a ribbon item, you need to understand the hierarchical
structure of the RibbonBar control and its item controls.

ribbon_hierarchy.png

To get a copy of a ribbon item control, use
the following two ways:

  1. (Recommended) You can get a
    copy of a ribbon item through its tag value.

    For example, suppose RibbonBar rbb_1
    contains a Category and the Category contains a Panel and the Panel
    contains a CheckBox (its Tag value is
    CheckBoxTag1). You can access the
    CheckBox with the following scripts.

  2. You can get a copy of a ribbon item according to its
    hierarchical level:

    RibbonBar > Category > Panel [> Group] >
    CheckBox/ComboBox

    RibbonBar > Category > Panel [> Group] >
    LargeButton/SmallButton [> RibbonMenu > MenuItem]

    RibbonBar > TabButton [> RibbonMenu >
    MenuItem]

    RibbonBar > ApplicationButton > ApplicationMenu >
    MenuItem (Master and/or Recent)

    Panel can directly contain CheckBox, ComboBox, LargeButton,
    and SmallButton. Group cannot contain LargeButton. ApplicationMenu
    can contain a list of master menu items and a list of recent menu
    items. For more, see Introduction to RibbonBar
    items
    .

    For example, suppose RibbonBar rbb_1
    contains a Category and the Category contains a Panel and the Panel
    contains a CheckBox. You first get a copy of the Category from
    RibbonBar rbb_1, and then get a copy of the
    Panel from the copy of the Category, finally get a copy of the
    CheckBox from the copy of the Panel. The code will look like
    this:

To set changes for a ribbon item control,
use different ways according to different item
controls:

  • For items in the Generic
    Controls
    category in the chart, including
    ApplicationButton, TabButton, Category, Panel, Group, CheckBox,
    ComboBox, LargeButton, and SmallButton, you can directly apply
    changes to the RibbonBar.

    For example, if you have changed the property of the CheckBox
    lr_CheckBox, to apply this change to the
    RibbonBar rbb_1, you write scripts like
    this:

    Or

    For differences between SetItem and SetCheckBox, refer to
    SetItem in PowerScript Reference.

  • For ApplicationMenu (its parent object is ApplicationButton)
    and RibbonMenu (its parent object can be TabButton, LargeButton, or
    SmallButton) in the Menu Controls
    category in the chart, you must first apply changes to the parent
    object and then to the RibbonBar.

    For example, if you have changed the text of the application
    menu lr_ApplicationMenu, to apply this change
    to the RibbonBar rbb_1, you write scripts
    like this:

  • For MenuItem (its parent object can be ApplicationMenu or
    RibbonMenu) in the Menu Controls
    category in the chart, you must first apply changes to the parent
    object, then to the parent object at one level higher, and finally
    to the RibbonBar.

    For example, if you have changed the text of the menu
    lr_MenuItem which is a dropdown of a large
    button, to apply this change to the RibbonBar
    rbb_1, you write scripts like this:

Example 1:

Suppose RibbonBar rbb_1 contains a Category
and the Category contains a Panel and the Panel contains a CheckBox (its
Tag value is CheckBoxTag1). The following
code gets the CheckBox by tag and then changes its Enabled
property:

Example 2:

Unlike the PowerBuilder traditional menu, to add/delete/modify a
ribbon menu item, you need to first get a copy of the menu item and its
parent object, make changes to the menu item, then set changes back to
its parent object, and finally to the RibbonBar control.

The following code example changes the text of a menu item
dynamically.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x