How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Post by galou_breizh »

For context, I'm trying to disable drag-and-drop for an object of type Part::FeaturePython in joint.py.

Thanks,
Gaël
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Post by wmayer »

Do you want to avoid that an object can be dragged, i.e. moved to a container object or avoid that other objects can be dropped on it?
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Post by galou_breizh »

I want to disable that another object is dropped on my custom object derived from Part::FeaturePython.
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Post by galou_breizh »

@wmayer
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to disable Drag-And-Drop for a 'Part::FeaturePython' object?

Post by Roy_043 »

Create a canDropObject function in the view provider class that always returns False.

Code: Select all

    def canDropObject(self, obj):
        return False
See for example:
https://github.com/FreeCAD/FreeCAD/blob ... w_layer.py
Post Reply