Skip to content

Commit 8121027

Browse files
committed
massaged page to closer inline with tone, updated code to include <ExtensionName>Page
1 parent 97fd8a7 commit 8121027

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

hub/powertoys/command-palette/command-results.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ no-loc: [PowerToys, Windows, Insider]
1111

1212
**Previous**: [Add top-level commands to your extension](add-top-level-commands-to-your-extension.md)
1313

14-
An [IInvokableCommand](./microsoft-commandpalette-extensions/iinvokablecommand.md) is a fundamental unit of *do something* in the Command Palette. The [Invoke](./microsoft-commandpalette-extensions/iinvokablecommand.md) method is called when the user selects the command, and it's where you *do something* in your extension. The **Invoke** method returns an **ICommandResult**, which tells the Command Palette what to do after the command has been invoked. This page details what's possible with each type of command result.
14+
An [IInvokableCommand](./microsoft-commandpalette-extensions/iinvokablecommand.md) represents a single actionable item in the Command Paletteit's what gets triggered when a user selects a command.
1515

16-
The toolkit provides a number of helper methods to create command results. These are all static methods on the **CommandResult** class. Calling these methods on their own won't do anything. You must return those objects as the result of a **Invoke** method, for Command Palette to handle them.
16+
When your command is selected, the [Invoke](./microsoft-commandpalette-extensions/iinvokablecommand.md) method is called. This is where you implement the logic for what your extension should do. The Invoke method must return an `CommandResult`, which tells the Command Palette how to respond after the command runs—for example, whether to show a message, open a file, or do nothing.
17+
18+
This page explains the 7 different types of `CommandResult` you can return and what each one does:
1719

1820
> [!NOTE]
1921
> There are code examples for the various CommandResult methods listed on this page.
@@ -22,28 +24,28 @@ The toolkit provides a number of helper methods to create command results. These
2224

2325
## KeepOpen command result
2426

25-
The **KeepOpen** command result does nothing. It leaves the palette in its current state, with the current page stack and query. This can be useful for commands that want to keep the user in the Command Palette, to keep working with the current page.
27+
The `KeepOpen` command result does nothing. It leaves the palette in its current state, with the current page stack and query. This can be useful for commands that want to keep the user in the Command Palette, to keep working with the current page.
2628

2729
> [!NOTE]
28-
> Even when returning **KeepOpen**, launching a new app or window from the Command Palette will automatically hide the palette the next window receives focus.
30+
> Even when returning `KeepOpen`, launching a new app or window from the Command Palette will automatically hide the palette the next window receives focus.
2931
3032
## Hide command result
3133

32-
This command result keeps the current page open, but hides the Command Palette. This can be useful for commands that want to take the user briefly out of the Command Palette, but then come back to this context.
34+
This command result keeps the current page open, but hides the Command Palette. This can be useful for commands that want to take the user briefly out of the Command Palette, but then come back to this context.
3335

3436
## GoBack command result
3537

3638
This result takes the user back a page in the Command Palette, and keeps the window visible. This is perfect for form pages, where doing the command should take you the user back to the previous context.
3739

3840
## GoHome command result
3941

40-
This result takes the user back to the main page of the Command Palette. It will leave the Palette visible (unless the palette otherwise loses focus). Consider using this for scenarios where you've changed your top-level commands.
42+
This result takes the user back to the main page of the Command Palette. It will leave the Palette visible (unless the palette otherwise loses focus). Consider using this for scenarios where you've changed your top-level commands.
4143

4244
## Dismiss command result
4345

4446
This result hides the Command Palette after the action is executed, and takes it back to the home page. On the next launch, the Command Palette will start from the main page with a blank query. This is useful for commands that are one-off actions, or that don't need to keep the Command Palette open.
4547

46-
If you don't know what else to use, this should be your default. Ideally, users should come into the palette, find what they need, and be done with it.
48+
If you don't know what else to use, this should be your default. Ideally, users should come into the palette, find what they need, and be done with it.
4749

4850
## ShowToast command result
4951

@@ -55,23 +57,20 @@ By default, [CommandResult.ShowToast(string)](./microsoft-commandpalette-extensi
5557

5658
## Confirm command result
5759

58-
This result displays a confirmation dialog to the user. If the user confirms the dialog, then the **PrimaryCommand** of the *ConfirmationArgs* will be performed.
60+
This result displays a confirmation dialog to the user. If the user confirms the dialog, then the `PrimaryCommand` of the `ConfirmationArgs` will be performed.
5961

6062
This is useful for commands that might have destructive actions, or that need to confirm user intent.
6163

6264
## Example
6365

64-
As an example, here's a page with one command for each kind of command result:
65-
66-
> [!NOTE]
67-
> If working from prior section, modify the code below from `CommandResultsPage` to `<ExtensionName>Page`.
66+
Below is a page with one command for each kind of command result:
6867

6968
```csharp
7069

7170
using Microsoft.CommandPalette.Extensions;
7271
using Microsoft.CommandPalette.Extensions.Toolkit;
7372

74-
internal sealed partial class CommandResultsPage : ListPage
73+
internal sealed partial class <ExtensionName>Page : ListPage
7574
{
7675
public CommandResultsPage()
7776
{

0 commit comments

Comments
 (0)