1e41f4b71Sopenharmony_ci# ArkUI Subsystem Changelog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## cl.arkui.1 Visual Effect Changes of the \<Menu> Component
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci**Access Level**
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciPublic
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci**Reason for Change**
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciThe changes are made to maintain consistency with UX specifications.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci- Changes the display effect shown when the set width is less than the minimum width.
14e41f4b71Sopenharmony_ci- Changes how the context menu interacts with the user.
15e41f4b71Sopenharmony_ci- Adds an attribute to allow a menu to display across applications (if this attribute is not specified, the system auto-displays the menu across applications based on the device type).
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci**Change Impact**
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciThe changes are compatible changes.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci- Allows the menu to display across applications.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci- Affects the avoidance logic of the context menu.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**API Level**
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci11
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**Change Since**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciOpenHarmony SDK 4.1.3.5
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Key API/Component Changes**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciMenu
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci- Before change:
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci  - If a custom menu is set to a width less than 64 vp, it is displayed at the width of 64 vp.
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci  - If there is no enough room for the context menu below the selected element, the context menu is flipped and displayed above the selected element instead.
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  - The submenu, if any, of a context menu, is displayed close to the edge.
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci  - The menu can only be displayed in the application window.
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci- After change:
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci  - If a custom menu is set to a width less than 64 vp, it is displayed at the width of two columns.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci  - If there is no enough room for the context menu below the selected element, the context menu is moved upward vertically until it is completely displayed, while respecting the minimum bottom margin requirement for the menu.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci  - The submenu, if any, of a context menu, is displayed with 12 vp left and right margins and 24 vp top and bottom margin, just like the context menu itself.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci  <img src="figures/SubMenu.jpg" alt="isSubWindow" style="zoom:50%;" />
56e41f4b71Sopenharmony_ci  
57e41f4b71Sopenharmony_ci  - You can use the **showInSubWindow** attribute to set whether to display the menu in a subwindow outside the application window on KLV devices. The value **true** means to show the menu in a subwindow outside the application window, and **false** means the opposite. If this attribute is not set, the menu is displayed in a subwindow outside the application window on KLV devices and inside the application window on non-KLV devices.
58e41f4b71Sopenharmony_ci  
59e41f4b71Sopenharmony_ci  <img src="figures/SubWindow.png" alt="SubWindow"  />
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**Adaptation Guide**
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci```
64e41f4b71Sopenharmony_ci/* Example of displaying the menu in a child window
65e41f4b71Sopenharmony_ci*(showInSubWindow?: boolean;)
66e41f4b71Sopenharmony_ci* Condition: KLV device
67e41f4b71Sopenharmony_ci* true: The menu is displayed in a subwindow outside the application window. 
68e41f4b71Sopenharmony_ci* false: The menu is displayed inside the application window.
69e41f4b71Sopenharmony_ci*/
70e41f4b71Sopenharmony_ci@Entry
71e41f4b71Sopenharmony_ci@Component
72e41f4b71Sopenharmony_cistruct Index {
73e41f4b71Sopenharmony_ci  @State select: boolean = true
74e41f4b71Sopenharmony_ci  private iconStr: ResourceStr = $r("app.media.view_list_filled")
75e41f4b71Sopenharmony_ci  private iconStr2: ResourceStr = $r("app.media.view_list_filled")
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci  @Builder
78e41f4b71Sopenharmony_ci  SubMenu() {
79e41f4b71Sopenharmony_ci    Menu() {
80e41f4b71Sopenharmony_ci      MenuItem({ content: "Copy", labelInfo: "Ctrl+C" })
81e41f4b71Sopenharmony_ci      MenuItem({ content: "Paste", labelInfo: "Ctrl+V" })
82e41f4b71Sopenharmony_ci    }
83e41f4b71Sopenharmony_ci  }
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci  @Builder
86e41f4b71Sopenharmony_ci  MyMenu(){
87e41f4b71Sopenharmony_ci    Menu() {
88e41f4b71Sopenharmony_ci      MenuItem({ startIcon: $r("app.media.icon"), content: "Menu option" })
89e41f4b71Sopenharmony_ci      MenuItem({ startIcon: $r("app.media.icon"), content: "Menu option" })
90e41f4b71Sopenharmony_ci        .enabled(false)
91e41f4b71Sopenharmony_ci      MenuItem({
92e41f4b71Sopenharmony_ci        startIcon: this.iconStr,
93e41f4b71Sopenharmony_ci        content: "Menu option",
94e41f4b71Sopenharmony_ci        endIcon: $r("app.media.arrow_right_filled"),
95e41f4b71Sopenharmony_ci        builder: ():void=>this.SubMenu()
96e41f4b71Sopenharmony_ci      })
97e41f4b71Sopenharmony_ci      MenuItemGroup ({ header: 'Subtitle' }) {
98e41f4b71Sopenharmony_ci        MenuItem ({ content: "Menu option" })
99e41f4b71Sopenharmony_ci          .selectIcon(true)
100e41f4b71Sopenharmony_ci          .selected(this.select)
101e41f4b71Sopenharmony_ci          .onChange((selected) => {
102e41f4b71Sopenharmony_ci            console.info("menuItem select" + selected);
103e41f4b71Sopenharmony_ci            this.iconStr2 = $r("app.media.icon");
104e41f4b71Sopenharmony_ci          })
105e41f4b71Sopenharmony_ci        MenuItem({
106e41f4b71Sopenharmony_ci          startIcon: $r("app.media.view_list_filled"),
107e41f4b71Sopenharmony_ci          content: "Menu option",
108e41f4b71Sopenharmony_ci          endIcon: $r("app.media.arrow_right_filled"),
109e41f4b71Sopenharmony_ci          builder: ():void=>this.SubMenu()
110e41f4b71Sopenharmony_ci        })
111e41f4b71Sopenharmony_ci      }
112e41f4b71Sopenharmony_ci      MenuItem({
113e41f4b71Sopenharmony_ci        startIcon: this.iconStr2,
114e41f4b71Sopenharmony_ci        content: "Menu option",
115e41f4b71Sopenharmony_ci        endIcon: $r("app.media.arrow_right_filled")
116e41f4b71Sopenharmony_ci      })
117e41f4b71Sopenharmony_ci    }
118e41f4b71Sopenharmony_ci  }
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci  build() {
121e41f4b71Sopenharmony_ci    Row() {
122e41f4b71Sopenharmony_ci      Column() {
123e41f4b71Sopenharmony_ci        Text('click to show menu')
124e41f4b71Sopenharmony_ci          .fontSize(50)
125e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
126e41f4b71Sopenharmony_ci      }
127e41f4b71Sopenharmony_ci      .bindMenu(this.MyMenu,{showInSubWindow:true})
128e41f4b71Sopenharmony_ci      .width('100%')
129e41f4b71Sopenharmony_ci    }
130e41f4b71Sopenharmony_ci    .height('100%')
131e41f4b71Sopenharmony_ci  }
132e41f4b71Sopenharmony_ci}
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```
135