Skip to content

Depress Condition — Highlight a Button

The addon currently supports Depress Condition only. A full "States" system (per-condition label/icon/color overrides) is not implemented — if you need that, see below.

Depress Condition lets a button highlight itself when a Python expression is True — useful for showing which choice is currently active (select mode, snap target, display mode, etc.) without needing a separate button per state.


How It Works

  1. Select a button.
  2. In the button editor, set Depress Condition to a Python expression (same rules as Conditions).
  3. When the expression evaluates to True, the button is drawn with the design's Button Active color (Design tab → ds_btn_act).
  4. That's the only override — label, icon, and custom color cannot be changed this way.
  5. Leave empty to disable — the button never highlights.

Example — Mesh Select Mode

Three buttons switching mesh select mode, each highlighting when active:

Vertex button:
  Operator: bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT')
  Depress Condition: context.tool_settings.mesh_select_mode[0]

Edge button:
  Operator: bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='EDGE')
  Depress Condition: context.tool_settings.mesh_select_mode[1]

Face button:
  Operator: bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE')
  Depress Condition: context.tool_settings.mesh_select_mode[2]

mesh_select_mode is a 3-tuple of booleans (vertex, edge, face). Don't confuse it with context.tool_settings.snap_elements, which controls snapping targets, not selection mode — a common mix-up since both use similar element names ('VERTEX', 'EDGE', 'FACE').

Example — Snap Element Active

Depress Condition: 'VERTEX' in context.tool_settings.snap_elements

Highlights the button when Vertex snapping is one of the active snap targets.


Need a Different Label, Icon, or Color?

Depress Condition only swaps the background to the active color — it can't change label, icon, or use a custom color per condition.

If you need that, make one button per state in the same slot, each shown only when its condition is True. Blender-side equivalent: two buttons occupying the same spot, only one drawn at a time.

How to Set It Up

  1. Create the button for state A (e.g. "Wireframe OFF" — the label/icon/color to show when the property is False).
  2. Set its Condition (in the button editor, under Operator/Property) to the expression that should be true for this state, e.g. not context.space_data.overlay.show_wireframes.
  3. Duplicate the button for state B ("Wireframe ON" — different label/icon/color).
  4. Set its Condition to the opposite expression: context.space_data.overlay.show_wireframes.
  5. Place both buttons in the same position (same pie direction / same grid slot). Since their conditions are mutually exclusive, only one is ever visible — the other collapses out of the layout, so it looks like one button that changes appearance.

Example — Wireframe Toggle (two buttons)

Button A:
  Type: PROPERTY
  Property path: context.space_data.overlay.show_wireframes
  Label: Wireframe
  Icon: MOD_WIREFRAME  (grey/default color)
  Condition: not context.space_data.overlay.show_wireframes

Button B:
  Type: PROPERTY
  Property path: context.space_data.overlay.show_wireframes
  Label: Wireframe ON
  Icon: MOD_WIREFRAME
  Override Colors: enabled, Button = green [0.2, 0.7, 0.3, 1.0]
  Condition: context.space_data.overlay.show_wireframes

Both toggle the same property; the Condition on each decides which one is shown. Use Override Colors on Button B for the custom green rather than relying on Depress Condition (which only offers the one fixed active color).