I have a checkbox in a panel. I have assigned a toggle hotkey to it. But when i press the hotkey then the checkbox does not change its state until you move with the mouse over the checkbox.
How can i force a redraw at the checkbox when i press the hotkey?
To reproduce, add keymap item with wm.context_toggle and the Context Attribute window_manager.deselect_bool
The script:
import bpy
from bpy.props import BoolProperty
class LayoutDemoPanel(bpy.types.Panel):
bl_label = "Demo Panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
wm = context.window_manager # Our bool is in the windows_manager
layout.prop(wm, "deselect_bool") # Our checkbox
def register():
bpy.types.WindowManager.deselect_bool = bpy.props.BoolProperty(
name="Checkbox", description="A checkbox", default = False)
bpy.utils.register_module(__name__)
def unregister():
del bpy.types.WindowManager.deselect_bool # Unregister our flag when unregister.
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
context.area.tag_redraw()
should work. Here is an example: gist.github.com/p2or/8a37617c4565e4ff143b736a0e4a1660 $\endgroup$ – p2or Jul 24 '16 at 14:10bl_info
first, but let me know if there is an error... In order to dive in, you can read: blender.stackexchange.com/questions/57306/… (I hope that's helpful at least). $\endgroup$ – p2or Jul 24 '16 at 16:39