Answer
Use a Sticky Key and generate a paired assignment with Save and Restore Previous Value. On press, PME stores the property’s current value and applies the temporary value. On release, it writes the stored value back.
This is safer than hard-coding an assumed release value because the user’s original state may have been either enabled or disabled.
The steps below were source-checked with PME 2.1 and Blender 4.5–5.2. The linked 2018 posts preserve the origin of the pattern rather than the present interface.
Steps
- Create a PME menu of type Sticky Key.
- Set On Press to a Command assignment for the property and temporary value.
- Use Save and Restore Previous Value in the Sticky Key editor. PME generates the paired press/release code.
- Assign the Sticky Key to a keymap where the property path is valid.
- Test twice: once with the original property off and once with it on. Both tests should return to their starting value after release.
For a property path represented here as target.property, the generated pattern is:
# On Press
value = target.property
target.property = temporary_value
# On Release
target.property = valueThe shared value variable is intentional: the Sticky Key runtime retains the press command’s globals until it runs the release command.
Block UI
Leave Block UI off for an ordinary temporary property unless the held Sticky Key must prevent other tools from receiving input. Blocking is most useful when the Sticky Key participates in a larger modal or Macro interaction. Enabling it unnecessarily can make Blender feel unresponsive while the key is held.
Pitfalls
- The property path must still resolve in the release context. Editor-specific paths require the pointer and keymap to remain in the intended area.
- Do not replace the generated restore command with a fixed opposite value; that destroys an existing user state.
- Complex multi-property changes need separate saved values and should restore every changed property.
- Test focus changes and modal tools before relying on the Sticky Key in production work.
Related answers
- Why an operator needs the correct Blender context
- Make one PME hotkey work in Object Mode and Edit Mode
- Use modifier keys inside one PME item