AndroidApps

Quick Tasker tip: Use %tap_label to create Menu actions more quickly

Tasker has several actions that create small scenes for you, for the purpose of not requiring the user to create full blown scenes for every little dialog box. One of those scene-creating actions is the Menu action, which creates a simple pop-up dialog menu with user-defined items. You can assign an action to each of these items, and in doing so decide what happens when that item is selected, but if you just need this for a list of user-defined values, there is a quicker way.

The local variable %tap_label is one of four built-in variables that are automatically populated based on tapping or selecting an item in a Menu scene element. %tap_label will contain the label (name) of the menu item tapped, and since the Menu action creates a scene that has a Menu scene element, this variable is also available there. What this means is that %tap_label will contain the name of the item you tapped in the Menu action-generated dialog box, just as it would if you made the scene yourself.

This can actually be quite useful, since it allows you to access the item name of the items you add to the Menu action without having to tie each item to a Variable Set action. So, instead of adding maybe 10 items and manually configuring each to do a Variable Set when selected, you just add the items without any actions linked to them, and access their names in %tap_label directly.

The limitation of this is that it’s only useful if the name of the item is indeed what you want to access later on. Examples include any type of pre-defined input, like a list of pre-defined SMS messages, a simple Yes/No dialog box, etc. The more items you need in the list, the more time you’ll save by doing this.

There is however another similar variable that you can also use, %tap_index. It will return the number of the item you tapped, so that if you tap the first option, it will be 1. It’s not as immediately useful for the Menu action as it is for the Menu scene element in a user-created scene, as the latter is more likely to be based off an array, but at least the option is there should you want it.

Even with this trick, the Menu action is better suited for quick dialog boxes. Without the ability to populate the menu with a variable or an array, like the Menu scene element in a user-created scene, its usefulness comes to a quick end with very long or in any way dynamic lists.

tasker banner - for some reason we don't have an alt tag here

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Andreas Ødegård

Andreas Ødegård is more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets. His day job as a teacher keeps him interested in education tech and takes up most of his time.

Avatar of Andreas Ødegård