Question
Can one PME menu item run a different action when Alt, Ctrl, or Shift is held?
Answer
Yes. In a PME Command item, E is the current Blender event supplied when the Command runs. Read E.alt, E.ctrl, and E.shift, then choose the action to run.
For example, this opens one of four PME menus:
open_menu(
"Alt Actions" if E.alt else
"Ctrl Actions" if E.ctrl else
"Shift Actions" if E.shift else
"Default Actions"
)The first matching branch wins. In this example, Alt has priority over Ctrl, and Ctrl has priority over Shift when more than one modifier is held.
When to keep it in one item
Use a short conditional expression when:
- all branches perform the same kind of task;
- the priority is obvious;
- each branch fits comfortably on one line.
Move the logic to an external script when it needs several conditions, shared setup, error handling, or comments. A long nested one-liner is valid Python but is difficult to review and maintain.
Event lifetime matters
E belongs to one PME invocation. It is available to Command execution and follows that invocation into Macro, Modal, Sticky, or Stack-Key execution where PME supports it.
Startup scripts, background tasks, and arbitrary Blender-console code have no PME opening event. Pass the needed modifier values into longer-lived code instead.
Verify
- Temporarily replace each action with a distinct
message_box()call. - Invoke the item with no modifier, then with Alt, Ctrl, and Shift.
- Test any combinations you expect users to press, such as Ctrl+Shift.
- Restore the real actions only after the branch order is clear.