protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams menuParams, CefMenuModel model) { model.InsertItemAt(model.Count > 0 ? 1 : 0, (int)CefMenuId.ReloadNocache, "Refresh"); model.AddSeparator(); model.AddItem(SHOW_DEV_TOOLS, "&Show DevTools"); model.AddItem(INSPECT_ELEMENT, "Inspect element"); CefMenuModel submenu = model.AddSubMenu(0, "Submenu Test"); submenu.AddItem((int)CefMenuId.Copy, "Copy"); submenu.AddItem((int)CefMenuId.Paste, "Paste"); submenu.SetColorAt(submenu.Count - 1, CefMenuColorType.Text, CefColor.FromArgb(Colors.Blue.ToArgb())); submenu.AddCheckItem(0, "Checked Test"); submenu.SetCheckedAt(submenu.Count - 1, true); submenu.AddRadioItem(0, "Radio Off", 0); submenu.AddRadioItem(0, "Radio On", 1); submenu.SetCheckedAt(submenu.Count - 1, true); }
public void Populate(ref CefMenuModel model, CefContextMenuParams context) { if (ShouldPopulate(context)) { if (ChildItems != null && ChildItems.Count > 0) { var childMenu = model.AddSubMenu(Id, Title); AddChildItems(ref childMenu, context); } else { switch (Type) { case "radio": model.AddRadioItem(Id, Title, GroupId <= 0 ? 1 : GroupId); if (Checked) { model.SetChecked(Id, true); } break; case "checkbox": model.AddCheckItem(Id, Title); if (Checked) { model.SetChecked(Id, true); } break; case "separator": model.AddSeparator(); break; default: model.AddItem(Id, Title); break; } } } }