SplitButton on Ribbon

Does anyone know how to configure an Action so it appears as a SplitButton on the Ribbon?
(I mean those buttons with an additional dropdown arrow like the Batch Tasks or Concordance Search buttons.)

The ActionStyle enum has PushButton and ToggleButton only, so: What's the trick?

Parents
  • Hi Angela,

    It is not possible to configure an action so that it appears as a Split Button on the Ribbon using the extensions from the Integration API.  The ActionLayout extension allows you to specify the DisplayType (ImageOnly, Normal, Large).

    If you are courageous, you could still achieve a similar result by creating a control that displays a combobox when the user clicks on the Action button.At a glance you would need to get access to the point on the screen of the control(action) that was clicked and then use that position to display the combobox control.

    The following example is by no means complete :-), but should give you an idea or get you started…

    [RibbonGroup("MyTestRibbonGroup", "TestGroupName")]
    [RibbonGroupLayout(LocationByType = typeof(TranslationStudioDefaultRibbonTabs.HomeRibbonTabLocation))]
    public class MyTestRibbonGroup : AbstractRibbonGroup{}

    [Action("MyTestRibbonGroupTestAction ", typeof(MyAwesomeView), Name = " TestName ", Icon = "TestIcon", Description = "TestDescription")]
    [ActionLayout(typeof(MyTestRibbonGroup), 1, DisplayType.Large)]

    public class MyTestRibbonGroupTestAction : AbstractAction
    {
        [DllImport("user32.dll")]
        static extern bool GetCursorPos(out Point lpPoint);

        [DllImport("user32.dll")]
        static extern IntPtr WindowFromPoint(System.Drawing.Point p);

        protected override void Execute()
        {                                            

            if (GetCursorPos(out var point))
            {
                 var hWnd = WindowFromPoint(point);

                 if (hWnd != IntPtr.Zero)
                 {
                     var control = Control.FromHandle(hWnd);
                     var studioWindow = control?.Parent;

                     var leftPosition = 30; //TODO find the actual rect of the action control as opposed to static assignment here
                     var topPosition = 100; //TODO find the actual rect of the action control as opposed to static assignment here
                     var location = new Point(studioWindow.Left + leftPosition , studioWindow.Top + topPosition)

                      if (studioWindow != null)
                      {                                                           
                            var comboboxControl = new MyAwesomeComboBoxControl
                            {
                                StartPosition = FormStartPosition.Manual,
                                Location = location
                            };                      

                            //Show your awesome combobox control
                            comboboxControl.ShowDialog(control);
                       }
                   }
              }
         }
    }

Reply
  • Hi Angela,

    It is not possible to configure an action so that it appears as a Split Button on the Ribbon using the extensions from the Integration API.  The ActionLayout extension allows you to specify the DisplayType (ImageOnly, Normal, Large).

    If you are courageous, you could still achieve a similar result by creating a control that displays a combobox when the user clicks on the Action button.At a glance you would need to get access to the point on the screen of the control(action) that was clicked and then use that position to display the combobox control.

    The following example is by no means complete :-), but should give you an idea or get you started…

    [RibbonGroup("MyTestRibbonGroup", "TestGroupName")]
    [RibbonGroupLayout(LocationByType = typeof(TranslationStudioDefaultRibbonTabs.HomeRibbonTabLocation))]
    public class MyTestRibbonGroup : AbstractRibbonGroup{}

    [Action("MyTestRibbonGroupTestAction ", typeof(MyAwesomeView), Name = " TestName ", Icon = "TestIcon", Description = "TestDescription")]
    [ActionLayout(typeof(MyTestRibbonGroup), 1, DisplayType.Large)]

    public class MyTestRibbonGroupTestAction : AbstractAction
    {
        [DllImport("user32.dll")]
        static extern bool GetCursorPos(out Point lpPoint);

        [DllImport("user32.dll")]
        static extern IntPtr WindowFromPoint(System.Drawing.Point p);

        protected override void Execute()
        {                                            

            if (GetCursorPos(out var point))
            {
                 var hWnd = WindowFromPoint(point);

                 if (hWnd != IntPtr.Zero)
                 {
                     var control = Control.FromHandle(hWnd);
                     var studioWindow = control?.Parent;

                     var leftPosition = 30; //TODO find the actual rect of the action control as opposed to static assignment here
                     var topPosition = 100; //TODO find the actual rect of the action control as opposed to static assignment here
                     var location = new Point(studioWindow.Left + leftPosition , studioWindow.Top + topPosition)

                      if (studioWindow != null)
                      {                                                           
                            var comboboxControl = new MyAwesomeComboBoxControl
                            {
                                StartPosition = FormStartPosition.Manual,
                                Location = location
                            };                      

                            //Show your awesome combobox control
                            comboboxControl.ShowDialog(control);
                       }
                   }
              }
         }
    }

Children