Skip to content

Commit b04ebea

Browse files
author
Joachim Marder
committed
Fixed issue #2: Sample projects with actions don't respond to mouse clicks
1 parent a566255 commit b04ebea

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

Lib/UIRibbon.pas

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -632,36 +632,35 @@ procedure TUIRibbon.DoCommandCreated(const pCommand: TUICommand);
632632
// When a Ribbon command is created, we check if there is a corresponding
633633
// TAction element available. If so, we assign the properties of that action
634634
// (Caption, Hint, etc.) to that ribbon element.
635-
if not Assigned(Self.RibbonMapper) or not Self.RibbonMapper.TryGetItem(pCommand.CommandId, lMarkupItem) then // Get the corresponding TAction for the given Ribbon command
636-
exit;
637-
638-
case pCommand.CommandType of
639-
TUICommandType.ctAction,
640-
TUICommandType.ctDecimal,
641-
TUICommandType.ctBoolean,
642-
TUICommandType.ctColorAnchor,
643-
TUICommandType.ctRecentItems:
644-
begin
645-
lAction := Self.GetActionForCommand(pCommand);
646-
if not Assigned(lAction) then
647-
raise Exception.Create(Format(sNoMappingFound, [lMarkupItem.Name, pCommand.CommandId]))
648-
else
649-
pCommand.Assign(lAction);
635+
if Assigned(Self.RibbonMapper) and Self.RibbonMapper.TryGetItem(pCommand.CommandId, lMarkupItem) then begin// Get the corresponding TAction for the given Ribbon command
636+
case pCommand.CommandType of
637+
TUICommandType.ctAction,
638+
TUICommandType.ctDecimal,
639+
TUICommandType.ctBoolean,
640+
TUICommandType.ctColorAnchor,
641+
TUICommandType.ctRecentItems:
642+
begin
643+
lAction := Self.GetActionForCommand(pCommand);
644+
if not Assigned(lAction) then
645+
raise Exception.Create(Format(sNoMappingFound, [lMarkupItem.Name, pCommand.CommandId]))
646+
else
647+
pCommand.Assign(lAction);
648+
end;
649+
// Try mapping ctAnchor (Tabs) to an action. If found, assign properties.
650+
// If not found, at least try to localize it.
651+
TUICommandType.ctAnchor: begin
652+
lAction := Self.GetActionForCommand(pCommand);
653+
if Assigned(lAction) then
654+
pCommand.Assign(lAction)
655+
else
656+
Self.LocalizeRibbonElement(pCommand, lMarkupItem);
657+
end
658+
else
659+
// If none of the types above, at least try to localize that command by
660+
// extracting the corresponding resource strings from the resource file.
661+
Self.LocalizeRibbonElement(pCommand, lMarkupItem);
650662
end;
651-
// Try mapping ctAnchor (Tabs) to an action. If found, assign properties.
652-
// If not found, at least try to localize it.
653-
TUICommandType.ctAnchor: begin
654-
lAction := Self.GetActionForCommand(pCommand);
655-
if Assigned(lAction) then
656-
pCommand.Assign(lAction)
657-
else
658-
Self.LocalizeRibbonElement(pCommand, lMarkupItem);
659-
end
660-
else
661-
// If none of the types above, at least try to localize that command by
662-
// extracting the corresponding resource strings from the resource file.
663-
Self.LocalizeRibbonElement(pCommand, lMarkupItem);
664-
end;
663+
end;//if RibbonMapper
665664
if Assigned(FOnCommandCreate) then
666665
FOnCommandCreate(Self, pCommand);
667666
end;

0 commit comments

Comments
 (0)