File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ layout : default
3
+ ---
4
+
5
+ # How to control object deletion
6
+
7
+ It is possible for a user to attempt to delete a DocumentObject while a Task
8
+ Dialog is attempting to update that object. Handling this in a Task Dialog
9
+ is not tidy.
10
+
11
+ ## Recommended reading:
12
+ - ViewProviders
13
+ - In/Out Lists
14
+
15
+ There are two methods in the ViewProvider that deal with this situation.
16
+
17
+ '''c++
18
+ bool canDelete(App::DocumentObject * obj)
19
+ '''
20
+ is called when Std_Delete is asked to delete obj, BUT it is called for each of
21
+ obj's parent in the InList. This is where you would decide if you will allow
22
+ one of your children can be deleted. In effect, the is canDeleteMyChildObject().
23
+ Return true to allow the child to be deleted, or false to prevent the deletion.
24
+
25
+ '''c++
26
+ bool onDelete(const std::vector< std::string > & parms)
27
+ '''
28
+ is also called when when Std_Delete is asked to delete a DocumentObject, but in
29
+ this case it is the DocumentObject's ViewProvider that is called. Return true
30
+ to allow deletion of the DocumentObject, or false to prevent the deletion.
31
+
32
+ Note that it is possible to circumvent these methods via scripting.
You can’t perform that action at this time.
0 commit comments