ReplaceCategoryByJSON

Description

Replaces an existing category with the category from a JSON file.

Applies to

RibbonBar control

Syntax

Integer controlname.ReplaceCategoryByJSON (long itemhandle, string data)

Argument

Description

controlname

The name of the RibbonBar control.

ItemHandle The handle for the category item for which you want to replace.
data The string of the category data in the required RibbonBar JSON format.

Return Value

Integer.

1 - Successful.

-1 - An internal error occurs.

-2 - The library fails to load.

-5 - Any of the following: 1) JSON syntax error; 2) JSON encode error; 3) JSON data is null.

If any argument's value is null, returns null.

Examples

An example of JSON file:

{
    "RibbonItems": {
        "Category": [
            {
                "Text": "Edit",
                "Tag": "Edit",
                "Enabled": true,
                "Visible": true,
                "Panel": [
                    {
                        "Text": "Undo",
                        "PictureName": "RibbonMenuButtonLarge!",
                        "Enabled": true,
                        "Visible": true,
                        "RibbonItem": [
                            {
                                "SmallButton": {
                                    "Text": "Undo",
                                    "Tag": "<Undo>",
                                    "PictureName": "RibbonSmallButtonDefault!",
                                    "Shortcut": "Ctrl+Alt+Shift+Z",
                                    "PowerTipText": "Undo",
                                    "Enabled": false,
                                    "Visible": true,
                                    "Checked": false,
                                    "DefaultCommand": false
                                }
                            }
                        ]
                    },
                    {
                        "Text": "Cut",
                        "PictureName": "RibbonMenuButtonLarge!",
                        "Enabled": true,
                        "Visible": true,
                        "RibbonItem": [
                            {
                                "SmallButton": {
                                    "Text": "Cut",
                                    "PictureName": "RibbonSmallButtonDefault!",
                                    "Shortcut": "Ctrl+X",
                                    "PowerTipText": "Cut",
                                    "Enabled": false,
                                    "Visible": true,
                                    "Checked": false,
                                    "DefaultCommand": false
                                }
                            },
                            {
                                "SmallButton": {
                                    "Text": "Copy",
                                    "PictureName": "RibbonSmallButtonDefault!",
                                    "Shortcut": "Ctrl+C",
                                    "PowerTipText": "Copy",
                                    "Enabled": false,
                                    "Visible": true,
                                    "Checked": false,
                                    "DefaultCommand": false
                                }
                            },
                            {
                                "SmallButton": {
                                    "Text": "Paste",
                                    "PictureName": "RibbonSmallButtonDefault!",
                                    "Shortcut": "Ctrl+V",
                                    "PowerTipText": "Paste",
                                    "Enabled": false,
                                    "Visible": true,
                                    "Checked": false,
                                    "DefaultCommand": false
                                }
                            },
                            {
                                "SmallButton": {
                                    "Text": "Clear",
                                    "PictureName": "RibbonSmallButtonDefault!",
                                    "PowerTipText": "Clear",
                                    "Enabled": false,
                                    "Visible": true,
                                    "Checked": false,
                                    "DefaultCommand": false
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

An example of calling ReplaceCategoryByJSON in scripts:

RibbonCategoryItem lr_Category2
Integer            li_Return
String             ls_tag, ls_ json	

ls_tag ="Window"
li_Return = mdirbb_1.getitembytag(ls_tag, lr_Category2)
If li_Return = 1 Then
	li_Return = mdirbb_1.replacecategorybyjson(lr_Category2.itemhandle,ls_json)
End If