How to access bone from PropertyGroup update function?

My addon uses a PropertyGroup (which is attached to EditBone). This PropertyGroup has various update callbacks which are used to update the bone when a setting changes.

My goal is: if the user changes a setting it will only apply to the active bone, but if the user selects multiple bones and uses Alt, it will apply to all the selected bones. This is the default behavior of Blender.

Normally I would use self.id_data to solve this problem, but that does not work with EditBone.

Here is an example .blend file:

Open it from the console, then hold down Alt and click the “Group enabled” checkbox (in the Test panel in the sidebar).

You will see that self.id_data is the Armature object, so I have no way of accessing the individual selected bones. How do I access the bone?

I can’t use context.active_bone, because then it does not work with multiple bones (using Alt). I can’t use context.selected_bones, because then it will always apply to all of the bones (even when not using Alt).

If you hold down Alt and click the “Direct enabled” checkbox, you will see that self is the EditBone, which is exactly what I want. But this only works for properties attached directly to the EditBone, it does not work for PropertyGroup.