Exemple #1
0
        /// <summary>
        /// Add a sub-menu to the menu. The new sub-menu is returned.
        /// </summary>
        public CefMenuModel AddSubMenu(int commandId, string label)
        {
            fixed(char *label_str = label)
            {
                var n_label = new cef_string_t(label_str, label.Length);

                return(CefMenuModel.FromNative(
                           cef_menu_model_t.add_sub_menu(_self, commandId, &n_label)
                           ));
            }
        }
Exemple #2
0
        private void on_before_context_menu(cef_context_menu_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_context_menu_params_t * @params, cef_menu_model_t *model)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mFrame   = CefFrame.FromNative(frame);
            var mState   = CefContextMenuParams.FromNative(@params);
            var mModel   = CefMenuModel.FromNative(model);

            OnBeforeContextMenu(mBrowser, mFrame, mState, mModel);

            mState.Dispose();
            mModel.Dispose();
        }
 protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
 {
     if (!webBrowser.menuVisible)
         model.Clear();
     int commandId = 1001;
     if (webBrowser.ContextMenu != null)
     {
         foreach (MenuItem item in webBrowser.ContextMenu.MenuItems)
         {
             if (item.Text == "-")
                 model.AddSeparator();
             else
                 model.AddItem(commandId, item.Text);
             CommandItem commandItem = new CommandItem();
             commandItem.id = commandId;
             commandItem.item = item;
             commandItems.Add(commandItem);
             commandId++;
         }
     }
     
     base.OnBeforeContextMenu(browser, frame, state, model);
     
 }
 /// <summary>
 /// Called before a context menu is displayed. |params| provides information
 /// about the context menu state. |model| initially contains the default
 /// context menu. The |model| can be cleared to show no context menu or
 /// modified to show a custom menu. Do not keep references to |params| or
 /// |model| outside of this callback.
 /// </summary>
 protected virtual void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
 {
 }
Exemple #5
0
 /// <summary>
 /// Returns the submenu at the specified |index| or empty if invalid.
 /// </summary>
 public CefMenuModel GetSubMenuAt(int index)
 {
     return(CefMenuModel.FromNativeOrNull(
                cef_menu_model_t.get_sub_menu_at(_self, index)
                ));
 }
Exemple #6
0
 /// <summary>
 /// Returns the submenu for the specified |commandId| or empty if invalid.
 /// </summary>
 public CefMenuModel GetSubMenu(int commandId)
 {
     return(CefMenuModel.FromNativeOrNull(
                cef_menu_model_t.get_sub_menu(_self, commandId)
                ));
 }
Exemple #7
0
 /// <summary>
 /// Called before a context menu is displayed. |params| provides information
 /// about the context menu state. |model| initially contains the default
 /// context menu. The |model| can be cleared to show no context menu or
 /// modified to show a custom menu. Do not keep references to |params| or
 /// |model| outside of this callback.
 /// </summary>
 protected virtual void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
 {
 }