From da24dfd4d0626ff72130d449a950c63561bc6766 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Tue, 30 Mar 2010 13:31:51 +0000 Subject: [PATCH] Fixed: SelectLast used the active group to start --- Source/X2CLMenuBar.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/X2CLMenuBar.pas b/Source/X2CLMenuBar.pas index 1240276..c9bcfe3 100644 --- a/Source/X2CLMenuBar.pas +++ b/Source/X2CLMenuBar.pas @@ -2656,12 +2656,26 @@ end; function TX2CustomMenuBar.SelectLast: TX2CustomMenuBarItem; +var + startGroup: TX2MenuBarGroup; + startItem: TX2CustomMenuBarItem; + begin Result := nil; + if Groups.Count = 0 then + Exit; if AllowInteraction then begin - Result := Iterate(FindEnabledItem, mbdUp); + { Start from the last item in the last group } + startGroup := Groups[Pred(Groups.Count)]; + + if startGroup.Items.Count > 0 then + startItem := startGroup.Items[Pred(startGroup.Items.Count)] + else + startItem := startGroup; + + Result := Iterate(FindEnabledItem, mbdUp, nil, startItem); if Assigned(Result) then SelectedItem := Result; end;