@@ -58,6 +58,7 @@ TUICommandCollectionActionLink = class(TUICommandActionLink)
5858 { $ENDREGION 'Internal Declarations'}
5959 protected
6060 procedure SetAction (Value : TBasicAction); override;
61+ procedure SetChecked (Value : Boolean); override;
6162 end ;
6263
6364 TUICommandDecimalActionLink = class (TUICommandActionLink)
@@ -139,14 +140,11 @@ TRibbonCollectionAction = class(TRibbonAction<TUICommandCollection>)
139140 fActionList: TList<TCustomAction>;
140141 fSelectedItem: Integer;
141142 fSelectionInitialized: Boolean;
142- fOriginalOnSelect: TUICommandCollectionSelectEvent;
143143 fUpdateCount: Integer;
144144 // / This flag indicates that a refresh should be performed as soon as the collection is not being displayed anymore.
145145 fRefreshWhenNotDisplayed: Boolean;
146146 function GetItem (pIndex: Integer): TCustomAction;
147147 procedure SetSelectedItem (const pValue: Integer);
148- // / Triggered on user induced selection changes. This handler will apply them to the action.
149- procedure UICommandItemSelected (const Args: TUICommandCollectionEventArgs);
150148 public
151149 constructor Create(AOwner: TComponent); override;
152150 destructor Destroy; override;
@@ -203,6 +201,7 @@ TRibbonCollectionAction = class(TRibbonAction<TUICommandCollection>)
203201 property SelectedItem: Integer read fSelectedItem write SetSelectedItem;
204202 published
205203 property ImageIndex;
204+ property Checked;
206205 end ;
207206
208207 // / <summary>
@@ -443,9 +442,13 @@ procedure TUICommandActionActionLink.SetAction(Value: TBasicAction);
443442
444443{ TUICommandCollectionActionLink }
445444
446- procedure TUICommandCollectionActionLink.CommandSelect (
447- const Args: TUICommandCollectionEventArgs);
445+ procedure TUICommandCollectionActionLink.CommandSelect (const Args: TUICommandCollectionEventArgs);
448446begin
447+ // Ignore events where the user only hovers over a selection. We only want to react to actual click events, i.e. when the selection changes.
448+ if Args.Verb <> TUICommandVerb.cvExecute then
449+ Exit;
450+
451+ (Action as TRibbonCollectionAction).SelectedItem := Args.ItemIndex;
449452 if Assigned(Action) then
450453 Action.Execute;
451454end ;
@@ -460,6 +463,14 @@ procedure TUICommandCollectionActionLink.SetAction(Value: TBasicAction);
460463 end ;
461464end ;
462465
466+ procedure TUICommandCollectionActionLink.SetChecked (Value : Boolean);
467+ begin
468+ inherited ;
469+ // Split button galleries have a "Checked" property, set it to the same state as
470+ // its corresponding TAction element has.
471+ (Client as TUICommandCollection).Checked := Value ;
472+ end ;
473+
463474{ TUICommandDecimalActionLink }
464475
465476procedure TUICommandDecimalActionLink.CommandChange (
@@ -681,17 +692,6 @@ procedure TRibbonCollectionAction.Remove(pAction: TCustomAction);
681692 RefreshCommandCollection;
682693end ;
683694
684- procedure TRibbonCollectionAction.UICommandItemSelected (const Args: TUICommandCollectionEventArgs);
685- begin
686- // Ignore events where the user only hovers over a selection. We only want to react to actual click events, i.e. when the selection changes.
687- if Args.Verb <> TUICommandVerb.cvExecute then
688- exit;
689-
690- fSelectedItem := UICommand.SelectedItem;
691- if Assigned(fOriginalOnSelect) then
692- fOriginalOnSelect(Args);
693- end ;
694-
695695procedure TRibbonCollectionAction.SetSelectedItem (const pValue: Integer);
696696begin
697697 fSelectedItem := pValue;
@@ -707,8 +707,6 @@ function TRibbonCollectionAction.Update(): Boolean;
707707 if Assigned(UICommand) and not (fSelectionInitialized) then
708708 begin
709709 UICommand.SelectedItem := fSelectedItem;
710- fOriginalOnSelect := UICommand.OnSelect;
711- UICommand.OnSelect := UICommandItemSelected;
712710 fSelectionInitialized := True;
713711 end ;
714712 if fRefreshWhenNotDisplayed and not IsCurrentlyDisplayed then
0 commit comments