Rename actions, multiple lines of actions above keyboard

Hi, I’m just starting to use the full version of drafts 5 and have a few questions.

  1. How do i rename actions?

  2. Is it possible to make multiples row of buttons above the keyboard so that I can access more functions quickly?

  3. Is it possible to see how an action was constructed so I can tweak actions in the drafts app? For example, if i download an action from the action directory, is there any easy way for me to make tweaks to how it works?

Thanks.

Swipe left to right on it in the list and select edit. You can rename in there.

No - only one row, but you could pop up prompts to let you choose from multiple options.

Yes. Edit the action as above for renaming. The action directory also shows you how the actions are constructed.

1 Like

It is not possible to display multiple rows simultaneously. It is possible to configure as many action groups to be available as keyboards as you like, and switch between them using the keyboard selector or by swiping up and down on the keyboard row.

1 Like

Awesome, thanks! How can I make popup prompts? Is this a different feature than the one that @agiletortoise described about using multiple keyboards?

Okay, I’ve quickly put together a full example for you.

First of all, here’s a keyboard enabled action group to download.

It contains four actions.

  1. Choose - this action pops up the menu to choose from a list of other actions. To make this self-contained, I’ve included the three actions it allows you to choose from in this action group.
  2. EG1 - this action inserts the current date in YYYY-MM-DD format.
  3. EG2 - this action inserts the current date in MM-DD-YYYY format.
  4. EG3 - this action inserts the current date in DD-MM-YYYY format.

When you select the Choose key it will pop-up a prompt with three buttons.

Note that the buttons display a description of what to do rather than the name of the action. I could have directly used the name of the action, but I figured this example could be more widely used and it might be better to be able to display different text that can be associated with the action. But likewise you could always display the name of the action.

When cancel is selected, an info message is popped up. When a button is selected, the associated action is run.

The script that does this is shown below. It takes a set of JSON where the key-value pairs are ‘button text-action name’ and then queues the selected action to run once the current one (the one displaying the prompt) completes.

//Define some JSON (key-value pairs), where the key is the button text to display
//and the value is the name of the action to run
let strActions = `
{
	"Date YYYY-MM-DD" : "EG1",
	"Date MM-DD-YYYY" : "EG2",
	"Date DD-MM-YYYY" : "EG3"
}
`

//Send the JSON off to a function to display it to the user for selection and running
chooseAndRunAction(strActions);


// Here are the functions that make it work

function promptButtonArray(p_strTitle, p_arrButtons)
{
	//Set-up the base prompt
	let promptButtonArray = Prompt.create();
	promptButtonArray.title = p_strTitle;

	//Create a button for each array item
	p_arrButtons.forEach(function(item)
	{
		promptButtonArray.addButton(item);
	});
	
	if (promptButtonArray.show())
	{
		return promptButtonArray.buttonPressed;
	}
	else
	{
		return "";
	}
}

function chooseAndRunAction(p_jsonActions)
{
	//initialise
	let actionData = JSON.parse(p_jsonActions);
	arrButtons = [];
	
	//Build an array of JSON keys
	for (key in actionData)
	{
		arrButtons.push(key);
	}
	
	//Pop-up some choices for the action to run
	let strResult = promptButtonArray("Run", arrButtons);

	//If we get a selection, queue up the action associated with the selection to run next.
	if (strResult == "") app.displayInfoMessage("Cancelled");
	else app.queueAction(Action.find(actionData[strResult]), draft);

	//Reactivate the editor in case it lost focus
	editor.activate();
}

You should just be able to duplicate and amend the JSON and any other parts of the action you wish for your own use, as many times as you wish.

Hope that helps.

1 Like