TRzToolButton Down and tsDropDown

Home Forums Konopka Signature VCL Controls (formerly Raize Components) TRzToolButton Down and tsDropDown

Viewing 4 reply threads
  • Author
    Posts
    • #1102
      Ján Kandrik
      Participant

        Hi! I am unable to use TRzToolbar Button GroupIndex (and Down property) together with ToolStyle=tsDropDown. If I set ToolStyle to tsDropDown, I am not able to set GroupIndex to anything else than zero (and therefore also using Down property does not do anything). I have the onClick event implemented (noticed different behavior when it is not implemented). Am I doing something wrong, or is this not possible?

      • #1109
        Ray Konopka
        Keymaster

          Hi,
          The behavior you are seeing is by design. Let me try to explain. The DropDown style allows a drop-down menu to be associated with the button. So that when you click on the arrow, a popup menu is displayed and the user can select one of the items from the menu. If you have an OnClick event handler (or an Action) assigned to the button, then the drop-down arrow portion is separated from the button itself. This allows you to have the button click perform some default behavior. Think of the File Open button in RAD Studio. The drop-down arrow provides access to a recently used list of files, and the button click displays the Open Dialog.

          The GroupIndex property is used in situations to allow the button to behave like a check-box or radio button. If the GroupIndex property value is shared across multiple buttons, then only one button in the set can be down at a time. Think of a set of text alignment buttons (Left, Center, Right). Only one of the buttons can be pressed at a time. If the GroupIndex values are unique for each button, then each button can work like a toggle. Think of the Bold, Italics, and Underline buttons.

          The AllowAllUp property works with the GroupIndex property to determine if all the buttons in a group (even a group of one) can all be in the Up state, or does one button have to be down.

          As a result, having a ToolButton in the DropDown style does not really fit in with the behavior of the grouping.

          Ray

        • #1113
          Ján Kandrik
          Participant

            Thank you very much for answering. In my use case I actually don’t need the button to be a part of a group, I only use “group of one” to make it work like a Toggle, just like You stated in your answer. I use it for some output filtering – clicking the button turns filtering on/off and by checking items in the dropdown, the user selects what he wants to see. Is there any way to make it work like that? In original Delphi TToolBar this was working correctly, however I was having some high DPI and layout issues so I tried TRzToolbar.

          • #1122
            Ray Konopka
            Keymaster

              The only way to change the behavior would be to modify the source code for the control. However, a simple alternative would be to use two buttons. One regular tool button with a unique GroupIndex and AllowAllUp set to True. Then use a separate tool button set to tsDropDown style and just resize it to make it thinner. You can even place it right next to the other button.

              Ray

            • #1216
              Ján Kandrik
              Participant

                Yes, that is one of the ways I tried. Bad thing is that the toolbar maintains some minimum width of a button and it just doesn’t look good. I ended with converting it to be menu only and included a “Show all” item in the menu. Thanks again for your time.

            Viewing 4 reply threads
            • You must be logged in to reply to this topic.