The short version: Mouse actions are not supported when recording macros, and they can’t be added after recording by inserting the appropriate keycodes in the JSON source (directly in Via, not in a file). Though there is a solution!
Introduction
Via has a lot of limitations, at least at first glance. Some of them can be overcome, e.g., changing the total number of key actions macros (default 150). Another is support of mouse actions.
The attempt
After recording, save first to transfer the recorded macro to the keyboard (if not, the recorded macro will be wiped out). Switch to the source view (this will read the information from the keyboard, hence why saving first is crucial). At the appropriate place, add this text to the macro source, using the appropriate keycode for mouse right click:
{KC_MS_BTN2}{100}
100 is a 100 ms separation between click down and click up. Its value isn’t critical.
When saving, this will result in:
“Whoops! Invalid keycodes detected inside{}: KC_MS_BTN2”
The same is using explicit press and release:
{+KC_MS_BTN2}{100}{-KC_MS_BTN2}{100}
Is there an escape?
For example, is it possible to use a numeric code instead of the symbolic key codes? A number enclosed in “{}” means a delay (the unit is milliseconds).