/// <summary> /// handle the context of a control /// </summary> /// <param name = "widget">: /// is the widget of the control \ tab \ table /// </param> /// <param name = "ctrl"> /// </param> private void handleContext(Control control, GuiMgControl guiMgControl, GuiMgForm guiMgForm) { ControlsMap controlsMap = ControlsMap.getInstance(); GuiMgMenu contextMenu = null; ContextMenu menu = null; ContextMenu prevMenu = (ContextMenu)control.ContextMenu; if (guiMgControl != null) { contextMenu = Events.OnGetContextMenu(guiMgControl); Form form = GuiUtilsBase.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 = (ContextMenu)controlsMap.object2Widget(menuRefernce); } if (menu != prevMenu) { GuiUtilsBase.setContextMenu(control, menu); } }
/// <summary> This method returns the current context menu. In case a context menu is not set on the object itself, we /// get the parent's context menu /// </summary> internal ContextMenu getContextMenu() { ControlsMap controlsMap = ControlsMap.getInstance(); ContextMenu ret = base.ContextMenu; if (ret == null) { GuiMgMenu contextMenu = Events.OnGetContextMenu(GuiMgControl); if (contextMenu != null) { Form form = GuiUtils.FindForm(_tableControl); MapData mapData = controlsMap.getFormMapData(form); MenuReference menuRefernce = contextMenu.getInstantiatedMenu(mapData.getForm(), MenuStyle.MENU_STYLE_CONTEXT); ret = (ContextMenu)controlsMap.object2Widget(menuRefernce); } } return(ret); }
/// <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; } } }