0

As title, although it is not a good practice to insert any additional button in a built-in menu. What if I meant to do so?

bpy.types.Menu only provide menu.prepend(call_func) and menu.append(call_func) to make custom draw method in front or behind the original buttons.

Illustrate menu append and prepend

Menu(bpy_struct) only said it is not possible to reference menus in Blender’s default scripts. So is the concept of draw is working like following code?

issubclass(menu, bpy.types.Menu)

if menu.prepend_callback: for menu_func in menu.prepend_callback: GUI.draw(menu_func)

GUI.draw(self.draw)

if menu.append_callback: for menu_func in menu.append_callback: GUI.draw(menu_func)

And If I really need to do insertion, I will need to insert the menu function directly inside the panels source code?

HikariTW
  • 7,821
  • 2
  • 18
  • 37
  • 3
    Related: Rearranging elements of a panel and Add Custom Menu at Specific Location in the Header - If not a menu, short answer is: currently not supported, as you figured out already. You can make it work as described in the answers I've linked to but it's hard to maintain if you want to build an addon from that. – p2or Aug 20 '20 at 08:35
  • @p2or Thanks for the information, it really help. At least it is still in Python scripting scope, there might be an elegant way to manage them in a universal solution. – HikariTW Aug 20 '20 at 08:53
  • @RayMairlot That one does (with doubt since those answer are old). Should I update another answer to make it 2.80 compatible or just keep using this Question? – HikariTW Aug 20 '20 at 11:57
  • 1
    @HikariTW I would either add your 2.8 code to one of the existing answers (but don't replace the 2.79 code) or if there isn't an easy way to update an existing answer, add a new answer to the duplicate. I would close this question either way. – Ray Mairlot Aug 20 '20 at 13:24

0 Answers0