/// <summary> This function is called when right click is pressed before opening the context menu. </summary> /// <param name = "guiMgControl"></param> /// <param name="line"></param> /// <returns></returns> private bool OnBeforeContextMenu(GuiMgControl guiMgControl, int line, bool onMultiMark) { //When right click is pressed on any control, we might need to move focus to that control //properly, I mean, we should also execute its CP, etc. bool focusChanged = false; if (guiMgControl is MgControl) { var mgControl = (MgControl)guiMgControl; // Click on a subform control is as a click on a form without control if (!guiMgControl.isSubform()) { ClientManager.Instance.RuntimeCtx.CurrentClickedCtrl = mgControl; processFocus(guiMgControl, line, false, onMultiMark); focusChanged = true; } } return(focusChanged); }
/// <summary> handle the context of a control /// /// </summary> /// <param name="widget">: /// is the widget of the control \ tab \ table /// </param> /// <param name="ctrl"> /// </param> public void handleContext(Control control, GuiMgControl guiMgControl, GuiMgForm guiMgForm) { ControlsMap controlsMap = ControlsMap.getInstance(); GuiMgMenu contextMenu = null; ContextMenuStrip menu = null; ContextMenuStrip prevMenu = control.ContextMenuStrip; GuiMgForm controlsForm = guiMgForm; if (guiMgControl != null) { // save the form that holds the control. if (guiMgControl.isSubform()) { controlsForm = guiMgForm; } else { controlsForm = guiMgControl.GuiMgForm; } contextMenu = Events.OnGetContextMenu(guiMgControl); Form form = GuiUtils.FindForm(control); MapData mapData = controlsMap.getFormMapData(form); guiMgForm = mapData.getForm(); } else { contextMenu = Events.OnGetContextMenu(guiMgForm); } if (contextMenu != null) { MenuReference menuRefernce = contextMenu.getInstantiatedMenu(guiMgForm, MenuStyle.MENU_STYLE_CONTEXT); menu = (ContextMenuStrip)controlsMap.object2Widget(menuRefernce); } // Fix bug#:927653, problem #2, when set context menu to the control need to refresh the event on the context menu // because on MgForm :instatiatedMenus is one per form per style (the style is the key) and it keeps only the menu // created for the last child of the form. // Qcr #909188 : Use the controlsForm to refresh menus action and not the 'form' which might be topmost. // The reason is that the form sent to OnRefreshMenuActions has to point to the task that holds the // control because it holds the relevant 'Action manager'. An action enabled for the control , might be disabled // in the top most form's task and be wrongly disabled in the context menu. if (controlsForm != null) { Events.OnRefreshMenuActions(contextMenu, controlsForm); } if (menu != prevMenu) { GuiUtils.setContextMenu(control, menu); //Save the control on which context menu is invoked. This is required later for creating dummy context menu. if (menu != null) { ((TagData)menu.Tag).MouseDownOnControl = control; } } }