What is context_pointer_set?

I ran across this in the API (context_pointer_set) but there’s not much of an explanation. I found a couple of examples of it in use (here and here), but deciphering its purpose from these contexts is beyond my current understanding of both Python and Blender UI coding.

Any information provided will be displayed on milk cartons around the world until this poor, lost child is returned home.

// space_userpref_keymap.py

def draw_km(self, display_keymaps, kc, km, children, layout, level):
    km = km.active()
    layout.context_pointer_set("keymap", km)

i guess:
context_pointer_set is being use to write keymap context to a pointer.
context_pointer_set(“context_pointer_type”, pointer)
context_pointer_set(“i_want_keyboard_context”, in_this_pointer)

there shoud be list somewhere with the different "context_pointer_type"s.

Thanks for the reply, dirty-stick. (great moniker, BTW. All kinds of entendres, double, triple and otherwise :slight_smile: )

That’s what I thought, too, but so far I haven’t found anything.

this is the code of the c-function:

void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *ptr){
    uiBlock *block = layout->root->block;
    layout->context = CTX_store_add(&block->contexts, name, ptr);

for me it looks like a function to set an arbitrary context, as properties may be context-dependent when adding them to a layout. If a prop isn’t in regular context, you set it via context_pointer_set() - just my guess :wink:

types i found:

  • modifier
  • constraint
  • edit_movieclip
  • edit_image
  • edit_image_user
  • object
  • controller
  • sensor
  • actuator
  • node

Hm… they could possibly be the same as bl_context for Panels!

1 Like

Or maybe windows? Is it some way to track which window/panel the mouse pointer if over? In the case of keymaps, that would make sense.