It's possible that you should add some features to the Context menu, especially if those features are ones that you use frequently. This menu gives you the ability to perform a wide variety of tasks. coordinates to display the popup menu in the correct location.Excel gives you access to a Context menu that is loaded with options whenever you right-click on a cell. get_Location returns coordinates in relation to upper left Bounds HMENU hPopupMenu = CHECK_POINTER(CreatePopupMenu()) ĬHECK_FAILURE(args->get_Location(&locationInControlCoordinates)) ICoreWebView2ContextMenuRequestedEventArgs* args)ĬHECK_FAILURE(args->get_MenuItems(&items)) Void PopulateContextMenu(CoreWebView2ContextMenuRequestedEventArgs args,Īrgs.SelectedCommandId = current.CommandId += delegate (object sender,ĬoreWebView2ContextMenuRequestedEventArgs args)ĬoreWebView2Deferral deferral = args.GetDeferral() Ĭm.Closed += (s, ex) => deferral.Complete() The following sample presents the WebView2 context menu in the Win32/WPF context menu format. COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SUBMENUĬOREWEBVIEW2_CONTEXT_MENU_TARGET_KIND enum.COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR.ICoreWebView2ContextMenuRequestedEventHandler ICoreWebView2ContextMenuRequestedEventArgs Test the COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND of each menu item, such as COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR or COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND. Iterate through a list of ICoreWebView2ContextMenuItem items, adding an ICoreWebView2ContextMenuItem for each menu item. On a ContextMenuRequested event, add an event listener that has an ICoreWebView2ContextMenuRequestedEventArgs. For this case, you specify Handled to be true, and request a deferral. To display a custom context menu that contains your desired menu items, use the data provided in ICoreWebView2ContextMenuRequestedEventArgs. CoreWebView2ContextMenuItemKind.Separator.CoreWebView2ContextMenuItemKind.Command.Kind of each menu item, such as Command or Separator.ĬoreWebView2ContextMenuRequestedEventArgs Class To include WebView2 context menu items in your app's context menu, iterate through the IList, adding a CoreWebView2ContextMenuItem for each menu item. The MenuItems property of CoreWebView2ContextMenuRequestedEventArgs provides the tree of the WebView2's context menu items for the right-clicked context. On a CoreWebView2.ContextMenuRequested event, add an event listener that has a CoreWebView2ContextMenuRequestedEventArgs. To display a custom context menu that contains your desired menu items, use the data provided in the CoreWebView2ContextMenuRequestedEventArgs of the CoreWebView2 ContextMenuRequested Event. When the user selects a command from your custom context menu, your app needs to tell the WebView2 control which command the user selected, by using the SelectedCommandId property. One of five types of menu item.Įither a default context menu (right-click menu) belonging to the WebView2 control, or a custom context menu (right-click menu) belonging to your host app. Includes checkbox, command, radio button, separator, and submenu.Ī narrow term. Remove default or custom menu items from the default context menu.Ī broad term. You can add default menu items and/or custom menu items to a custom context menu.Īdd default menu items to a custom context menu.Īdd custom menu items to a default context menu. For this case, you handle the event and request a deferral. You can use the data provided in the Event arguments of ContextMenuRequested to display a custom context menu with entries of your choice. Your app handles the ContextMenuRequested event. Instead of using the default context menu, your host app can draw its own context menu by using the information that's sent from the WebView2 context menu. For example, you can do any of the following: Use the ContextMenuRequested API to customize the context-menus (right-click menus) of a WebView2 app. The WebView2 control provides a default context menu, and you can create your own context menu when using a WebView2 control.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |