How can I create a panel that allows me to add custom properties (StringProperty
, BoolProperty
, etc) for Collections? I want to show a GUI in the object properties when the user clicks a collection in the outliner. To create a panel you normally inherit from bpy.types.Panel
and implement the draw()
. The poll()
function can be used to determine if the panel should be shown or not. The obvious approach is to use this feature. But how would this poll()
look like? How do you know if a collection has been clicked by the user as shown in the screenshot below.
When "my-collection" is clicked/selected I want to show a panel in the object properties. But how do I know if a collection has been clicked?
Update 1
I'll try to clarify the issue a bit more. In the image above I've made the "Sub" collection active. When I print the name C.collection.name
you see that it prints "Sub". Now, let me make "Cube" active:
Now, when I print C.collection.name
it prints "Sub" again; and although that's correct, that's not the info I'm trying to retrieve. I need to query some other context value which would give me the collection when "Sub" is active and "Cube" when the object is active.