* * *

Author Topic: Disabled action of drop-down button prevents access to drop-down menu  (Read 555 times)


  • New member
  • *
  • Posts: 30
I have a drop-down menu attached to drop-down button on a toolbar. It may be that some items of this menu are disabled, while others are not. Problem is that if Action, associated with the button is disabled, then not only the button itself, but also arrow which invokes the menu is disabled.

So, is it possible to access drop-down menu when the action, associated with the button, is disabled?

Thank you in advance!


As a workaround I did following: wrote a function which, if a button is disabled, finds enabled Item in its menu and associates this item with the button:
Code: Pascal  [Select]
  1. procedure TMainForm.FindActiveAction(Btn: TToolButton);
  2. var
  3.   I: Integer;
  4.   TheAction:TAction;
  5. begin
  6.   with Btn do
  7.   begin
  8.     if (Style <> tbsDropDown) or Enabled then Exit;
  9.     for I := 0 to DropDownMenu.Items.Count - 1 do
  10.     begin
  11.       TheAction := TAction(DropDownMenu.Items[I].Action);
  12.       if Assigned(TheAction) and TheAction.Enabled then
  13.         Action := TheAction;
  14.     end;
  15.   end;
  16. end;

and call this from Idle for each button where such situation is possible.

So, whenever a "title" action is disabled for a button with drop-donw menu, it is replaced with an active one.
« Last Edit: August 04, 2017, 05:29:14 pm by glorfin »



Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus