Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Determine toolclick source
posted

Hello,

I have a WinfForms dialog that presents the same drop-down menu options in two different areas - one within an UltraDropDownButton, and the other within the toolbar itself.

Even though both of these areas share a drop-down menu, I need to know which is the source within the ToolClick event.

Does anyone know how to do this? My original thought was that I could just set a flag when the dropdown button opens, and then reset it when it closes - but unfortunately it closes before the ToolClick event is fired, which makes that approach infeasible.

Any help would be greatly appreciated.

Parents
No Data
Reply
  • 6158
    Suggested Answer
    Offline posted

    Hello,

    When displaying the child tools of a PopupMenuTool in a context of other than a UltraToolbar (such as a context menu or the dropdown of the UltraDropDownButton), the UltraToolbarsManager displays the root tool, and not the instance tool which is displayed on the toolbar.

    In your scenario, the first thing you'll need to do is find the top-level tool being used for the display (PopupMenuTool) by recursively checking the Owner property until it is not of type ToolBase. Once you get this tool, you can check the IsRootTool property to determine if it is an instance tool (i.e on a UltraToolbar) or a root tool (i.e being displayed as a dropdown/context menu).

    <within the ToolClick event handler>

                ToolBase tool = e.Tool;
                while (tool.Owner is ToolBase)
                    tool = tool.Owner as ToolBase;

                if (tool.IsRootTool)
                {
                    // Perform UltraDropDownButton Tool Click functionality
                }
                else
                {
                    // Perform UltraToolbar Tool Click functionality
                }

    If I can assist you with any other questions regarding this scenario, please don't hesitate to ask.

    Thanks,

    Chris

     

Children