PDA

View Full Version : using callbacks to stop a node from being deleted


jonlauf
06-14-2006, 06:37 PM
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

suck
06-16-2006, 01:33 PM
this is way hacky, but you could force an undo.

f97ao
06-16-2006, 02:37 PM
fn FW_ToolsUndoDelete theNode=
(

if theNode==FW_MotherObject and FW_DetailMode then
(
qDelete=queryBox "Are you sure you want to delete the Detail Area?\nThis 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

jonlauf
06-16-2006, 10:24 PM
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

f97ao
06-19-2006, 08:55 AM
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

CGTalk Moderation
06-19-2006, 08:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.