Skip to content

Commit 01e488c

Browse files
committed
Add menu
1 parent 0f03db1 commit 01e488c

3 files changed

Lines changed: 45 additions & 10 deletions

File tree

  • content/en/docs/apidocs-mxsdk/apidocs
    • studio-pro-10/extensibility-api/csharp/extensibility-api-howtos
    • studio-pro-11/extensibility-api/csharp/extensibility-api-howtos

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/extensibility-api/csharp/extensibility-api-howtos/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ description_list: true
99

1010
## Introduction
1111

12-
The following how-tos teach you how to use the Extensibility API for C# Developers in different use cases.
12+
The following how-tos describe how to use the C# Extensibility API in different use cases.

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/extensibility-api/csharp/extensibility-api-howtos/add-menu.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ weight: 15
77

88
## Introduction
99

10-
This how-to describes how you can add a menu that contains submenus, some of which also contain submenus of their own. Before you start this how-to, it is recommended to [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-menu-extension/) first.
10+
This how-to describes how to add a menu that contains sub-menus, some of which also contain sub-menus of their own.
1111

1212
You can download the example in this how-to in [this GitHub repository](https://github.com/mendix/ExtensionAPI-Samples).
1313

14+
## Prerequisites
15+
16+
This how-to uses the results of [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-menu-extension/). Complete that how-to before starting this one.
17+
1418
## Creating Menu Extension Class
1519

16-
1. Open the project that you previously created when you followed [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-menu-extension/).
17-
2. Add a new class to the project and name it `MyMenuExtension.cs`.
18-
3. Replace the code in the file with the following code:
20+
1. Open the project you created when following [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/create-menu-extension/).
21+
2. Add a new class to the project and name it *MyMenuExtension.cs*.
22+
3. Replace the code in the file with the following:
1923

2024
```csharp
2125
using Mendix.StudioPro.ExtensionsAPI.UI.Menu;
@@ -57,10 +61,41 @@ You can download the example in this how-to in [this GitHub repository](https://
5761
}
5862
```
5963

60-
The code above creates a single menu, `Beverages`, which contains the submenus `Hot` and `Cold`, both of which contain some submenus. Note that when you are creating this menu structure, you only return the main parent menu (in this example, the `Beverages` menu) from the `GetMenus` method. You should only return the topmost parents in your list, so only the ones that do not have a parent should be returned. In the example above, there is only one.
64+
### Menu Structure Overview
65+
66+
The code above creates a single menu, `Beverages`. This menu contains the following:
67+
68+
* `Beverages` contain two sub-menus: `Hot` and `Cold`
69+
* `Hot` contains `Coffee` and `Tea`
70+
* `Coffee` contains `Black Coffee`, `Decaf`, and `Espresso`
71+
* `Espresso` contains `Regular Espresso` and `Ristretto`
72+
* `Cold` contains `Soda`
73+
74+
Only the top-most parent menu (`Beverages`) is returned from the `GetMenus` method. You should only return menus that do not have a parent.
75+
76+
### Menu Placement
77+
78+
If an app contains one or more extensions, a top-level menu named `Extensions` will appear in the main menu bar of Studio Pro.
79+
80+
Menus that are created from `MenuExtension` implementations are grouped by their extension entry point name (in this example, `MyCompany`), and are placed under a dedicated sub-menu. For example, `MyMenuExtension` will be placed as follows: **Extensions** > **MyCompany** > **MyMenuExtension**.
81+
82+
### Menu Properties
83+
84+
A menu can either:
85+
86+
* Be a parent (a menu that contains sub-menus), or
87+
* Have an action
88+
89+
You cannot create a menu that both contains sub-menus and has an action.
90+
91+
#### Separators
92+
93+
You can add a `MenuSeparator` to a menu using the `Separator` property. The options include:
6194

62-
If an app contains one or more extensions, a top-level menu named `Extensions` will appear in the main menu bar of Studio Pro. Menus that are created from `MenuExtension` implementations will be grouped by their extension entry point name (in this example, `MyCompany`), and then placed under their own dedicated submenu under the main `Extensions` top-level menu. For example, the `MyMenuExtension` above will be placed as follows: **Extensions** > **MyCompany** > **MyMenuExtension**.
95+
* `After`
96+
* `Before`
97+
* `None` (default).
6398

64-
A menu can only be a parent (namely, a menu that contains submenus) or have an action. You cannot create a menu with an action which also contains submenus.
99+
#### Enabling and Disabling Menus
65100

66-
You can add a `MenuSeparator` to a menu, via the `Separator` property. Options are `After`, `Before` or `None`. The default value is `None`. You can also disable a menu by setting its `IsEnabled` property to `false`. Menus are enabled by default.
101+
Menus are enabled by default. To disable a menu, set its `IsEnabled` property to `false`.

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/add-menu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This how-to uses the results of [Create a Menu Extension Using C#](/apidocs-mxsd
1818
## Creating Menu Extension Class
1919

2020
1. Open the project you created when following [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/create-menu-extension/).
21-
2. Add a new class to the project and name it `MyMenuExtension.cs`.
21+
2. Add a new class to the project and name it *MyMenuExtension.cs*.
2222
3. Replace the code in the file with the following:
2323

2424
```csharp

0 commit comments

Comments
 (0)