Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

Delphi Haven: FMX menu unfurling speed

$
0
0

A bit ago I posted a QC report complaining about the speed at which a nested FMX popup menu unfurls. Steps:

  1. Create a new FMX desktop application.
  2. Add a TPopupMenu to the form, then four items to the popup menu, the second parented to the first, the third to second and the fourth to the third.
  3. Add a TRectangle to the form and assign its PopupMenu property to PopupMenu1.
  4. Right click on the popup menu, select the first item then hover over the second; once the third item is shown, hover over it to show the fourth.

Expected: the menu unfolds quickly.
Actual: the menu unfolds sloooowly.

At the time I thought FMX menus were just slow… until it recently got pointed out to me that the FMX source in fact hardcodes a delay of 500ms. As such, if you require quickly unfurling menus, just take a copy of FMX.Menus.pas and change the value assigned to FDelay in the constructor for TAutopopupMenuTimer (line 575 in XE5 RTM).

That said, ideally, the correct value would be got from the OS; for Windows, the API function to call is SystemParametersInfo:

uses
  WinApi.Windows;

function GetMenuShowDelay: Integer;
var
  Value: DWORD;
begin
  SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, @Value, 0);
  Result := Value;
end;

To be honest, I’m not sure what the OS X equivalent (if there is one) is, so if anyone knows, feel free to tell all in the comments…



Viewing all articles
Browse latest Browse all 1725

Trending Articles