Page MenuHome

Drag & Drop: Support Open/Link/Append when dropping .blend file
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Oct 16 2018, 2:40 PM.

Details

Summary

When a .blend file is dropped into Blender a small menu opens.
In that menu the user can choose between three options: Open, Link and Append.

One "difficulty" in implementing this was the wm.link and wm.append operators for some reason automatically execute when the filepath is set.
Some other similar operators do that as well. I think this behavior should be removed from all those operators.
If someone wants to execute it directly he can just set the right execution context (like EXEC_DEFAULT) so that the file selector is not opened.

There are cases (like this one) when one wants to set the filepath as default but the file selector should still be opened.

Implementation Detail: I'm unsure if it is safe to call the popup_menu function like this. Are the operator props available as long as there is a reference to the operator? I could also make the draw_menu function independent of the operator but it looks nicer if everything is in one class.

Diff Detail

Repository
rB Blender
Branch
drop_blend_options (branched from blender2.8)
Build Status
Buildable 2276
Build 2276: arc lint + arc unit

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Oct 22 2018, 2:12 PM

Fair enough about still opening the file browser even if the filepath is set. I don't think we considered that use case.

Implementation Detail: I'm unsure if it is safe to call the popup_menu function like this. Are the operator props available as long as there is a reference to the operator? I could also make the draw_menu function independent of the operator but it looks nicer if everything is in one class.

This is safe as far as I can tell, the operator Python instance stays alive as long as the operator is running.

release/scripts/startup/bl_operators/wm.py
2680

Rename operator to WM_OT_drop_blend_file for consistency and brevity.

2687

This should be invoke() I think? Generally exec() is only for cases where there is no user interaction.

This revision now requires changes to proceed.Oct 22 2018, 2:12 PM

This is safe as far as I can tell, the operator Python instance stays alive as long as the operator is running.

Yes, the problem might be that the operator is independent of the menu. The operator itself has no user interaction. The only thing it does is to open a menu with some specific settings.
Anyway, maybe I'm just searching for a problem where there is none.

Yes, the problem might be that the operator is independent of the menu. The operator itself has no user interaction. The only thing it does is to open a menu with some specific settings.
Anyway, maybe I'm just searching for a problem where there is none.

I'm quite sure this is fine, if it wasn't we'd have issues with lots of other operators that open menus too.

  • implement suggested changes
This revision is now accepted and ready to land.Oct 22 2018, 5:08 PM
This revision was automatically updated to reflect the committed changes.