The number one request I get for Buttons is the ability to run multiple things with one button click. I'm looking into the best way to support that. In the meantime, there are two other community plugins that can run multiple commands: QuickAdd and Macros. You can use these with Buttons to fulfill your multiple commands in a single click dreams.
Note: If you want to cycle through different commands when clicking a button multiple times then check out Swap Buttons. They are a special type of Inline Button!
Macros is a community plugin that lets you chain together multiple commands from the command palette into a single command. It can be installed via the community plugin directory.
Creating a new Macro is really easy. Open Macros settings and click the + button. A modal will show up with some options:
Let's make a simple Macro that creates a vertical split, opens my daily notes page, and pins the pane.
Here's my DNP Split Macro:
You can run a Macro directly from the Command Palette:
If you want to learn how to use this Macro in a Button go to the Combine with Buttons Section.
The QuickAdd community plugin can also create Macros. It is a more complex plugin with a bunch of additional features like inserting templates or text. Let's setup a macro in QuickAdd next.
QuickAdd can do a lot of things. It can feel a bit overwhelming to get started. I highly recommend going through the examples in the github repo and playing around with all the features to get comfortable with this super powerful tool.
Why would you use QuickAdd instead of Macros? QuickAdd can run commands, but it can also insert text or templates into a note, or even create a new note from a template. For anyone who needs these advanced features, QuickAdd macros are great!
In the OMG Discord, user @Kippy wanted to make a button that ran a command and then added text to their current note.
This isn't possible inside Buttons, but we can make a QuickAdd Macro that does this! Install QuickAdd and open the QuickAdd Settings. To add a Macro, click the Manage Macros button.
In the Macro Manager input a name for your new Macro and click the Add Macro button.
The new Macro will appear in the list of Macros. Click the Configure button to start editing what the Macro does. Macros in QuickAdd can do a bunch of different things!
To create the Pomodoro button that @Kippy wants, we'll need to use the Obsidian Command and Capture options.
I typed in the Pomodoro command and hit Add, and clicked the Capture button. Notice how my Capture action is called "Untitled Capture Choice"? That's because I need to configure it still. I can do that by clicking the gear icon.
These settings automatically save, so when you're done you can close the modal. One thing Capture can't do is insert the text at a specific line in the note (as far as I could tell). Maybe the plugin developer will add that option in the future!
Now that the QuickAdd macro is all setup, we're almost ready to trigger it with a button. The last step is to add it to the list of QuickAdd choices and enable it to appear in the command palette.
The next section will show you have to turn the macros into Buttons
The easiest way to make a new button is with the Button Maker. Open the command palette and choose the Button Maker command. This will pop up a WYSIWG modal to create your new button.
The inserted button should look like:
It's hard to show this Button in action, but it will pause the Pomodoro Timer and insert the text specified in the QuickAdd Macro. If you want the text inserted at a specific line, you could investigate building a Templater command that does this, or writing a custom JavaScript action.
In this tutorial we built two multi-command Buttons. One was simple using the Macros community plugin. The other was more powerful and used QuickAdd.
I'm not an expert in either of these plugins (especially QuickAdd), so if I did something wrong, or there are better approaches, let me know in the OMG Discord.
Catch y'all next time!