[Closed] using callbacks to stop a node from being deleted
Hi,
Does anyone know if there is a way to use the #selectedNodesPreDelete callback to prevent a node from being deleted. I tried calling a function within the callback that removed the item from the callbacks.notificationParam() array then selected the new array, but it deleted the item anyway. Any help would be greatly appreciated. Thanks, Jon
fn FW_ToolsUndoDelete theNode=
(
if theNode==FW_MotherObject and FW_DetailMode then
(
qDelete=queryBox "Are you sure you want to delete the Detail Area?
This cannot be undone." title:"PolySpeed Warning"
--qDelete=false
if not(qDelete) then
(
newNode=FW_ToolsTrueCopy theNode
FW_MotherObject=newNode
)
else
callbacks.removeScripts id:#DetailDeleteProtection
)
FW_UpdateRunning #on
)
fn FW_ToolsTrueCopy theNode =
(
--theNode =$
if IsValidNode theNode do
(
startName=theNode.name
startWireColor=theNode.wirecolor
theNode.name+="_copyTemp"
newNode=copy theNode
newNode.name=startName
newNode.wirecolor=startWirecolor
select newNode
newNode
)
)
This is cut and pasted from PolySpeed. This is the way I make sure that the user don’t delete stuff they shouldn’t delete. Basically I just copy the object and transfer the name and wirecolor to it.
Hope that helps.
/Andreas
Thanks Andreas, that works great! I just needed to add a getUserProp and setUserProp in the copy function to retain some extra data, but that was it.
–Jon
Glad it worked. If you find any better ways of doing it please tell. I just added it so haven’t tested it that much. It seems to work fine though.
/A