HandleCommandEntry() takes a CommandListEntry and executes it returning true iff successful. If you pass any flags, the command won't be executed unless the flags are compatible with the command's flags.
| 817 | ///the command won't be executed unless the flags are compatible |
| 818 | ///with the command's flags. |
| 819 | bool CommandManager::HandleCommandEntry(const CommandListEntry * entry, |
| 820 | CommandFlag flags, bool alwaysEnabled, const wxEvent * evt, |
| 821 | const CommandContext *pGivenContext) |
| 822 | { |
| 823 | if (!entry ) |
| 824 | return false; |
| 825 | |
| 826 | if (flags != AlwaysEnabledFlag && !entry->enabled) |
| 827 | return false; |
| 828 | |
| 829 | if (!alwaysEnabled && entry->flags.any()) { |
| 830 | |
| 831 | const auto NiceName = entry->label.Stripped( |
| 832 | TranslatableString::Ellipses | TranslatableString::MenuCodes ); |
| 833 | // NB: The call may have the side effect of changing flags. |
| 834 | bool allowed = ReportIfActionNotAllowed(NiceName, flags, entry->flags); |
| 835 | // If the function was disallowed, it STILL should count as having been |
| 836 | // handled (by doing nothing or by telling the user of the problem). |
| 837 | // Otherwise we may get other handlers having a go at obeying the command. |
| 838 | if (!allowed) |
| 839 | return true; |
| 840 | mNiceName = NiceName; |
| 841 | } |
| 842 | else { |
| 843 | mNiceName = {}; |
| 844 | } |
| 845 | |
| 846 | CommandContext context{ mProject, evt, entry->index, entry->parameter }; |
| 847 | if (pGivenContext) |
| 848 | context.temporarySelection = pGivenContext->temporarySelection; |
| 849 | ExecuteCommand(context, evt, *entry); |
| 850 | return true; |
| 851 | } |
| 852 | |
| 853 | void CommandManager::ExecuteCommand(const CommandContext &context, |
| 854 | const wxEvent *evt, const CommandListEntry &entry) |
no test coverage detected