# Class (ContextMenuController) 提供控制菜单关闭的能力。 > **说明:** > > - 本模块首批接口从API version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > > - 本Class首批接口从API version 12开始支持。 > > - 以下API需先使用UIContext中的[getContextMenuController()](./arkts-apis-uicontext-uicontext.md#getcontextmenucontroller12)方法获取ContextMenuController实例,再通过此实例调用对应方法。 ## close12+ close(): void 关闭菜单。 **原子化服务API:** 从API version 12开始,该接口支持在原子化服务中使用。 **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** 通过定时器触发,调用ContextMenuController的close方法关闭菜单。 ```ts import { ContextMenuController } from '@kit.ArkUI'; @Entry @Component struct Index { menu: ContextMenuController = this.getUIContext().getContextMenuController(); @Builder MenuBuilder() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('Test ContextMenu1 Close') Divider().strokeWidth(2).margin(5).color(Color.Black) Button('Test ContextMenu2') Divider().strokeWidth(2).margin(5).color(Color.Black) Button('Test ContextMenu3') } .width(200) .height(160) } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button("启动定时器").onClick(()=> { setTimeout(() => { this.menu.close(); }, 10000); }) Column() { Text("Test ContextMenu close") .fontSize(20) .width('100%') .height(500) .backgroundColor(0xAFEEEE) .textAlign(TextAlign.Center) } .bindContextMenu(this.MenuBuilder, ResponseType.LongPress) } .width('100%') .height('100%') } } ``` ![contextMenuController_close](figures/contextMenuController_close.gif)