cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Callback on DELETE key

gbélanger
12-Amethyst

Callback on DELETE key

I need to add a callback on when the DELETE key is pressed.  I don't need to change the behavior of the key pressing but only to detect it and being able to run a function additionally to the normal process.

 

Thanks for your time.

ACCEPTED SOLUTION

Accepted Solutions

Good afternoon, thanks for taking the time to answer me back.  I ended up using the following code:

 

doc_add_callback(current_doc(), 'delete', 'triggerDelete');

...

function triggerDelete(doc, op){
	local tickEvent;
	if($op == 1 && numerotationHelper::insertionInProgress == 0){
		# callback are always called twice
		# https://support.ptc.com/help/arbortext/r8.1.0.0/en/index.html#page/Program/acl_ref/help148-517.html
		numerotationHelper::lastDeletePressed = javascript('d = Date.now();d.toString();');
		local selectedElement = selected_element();
		if(index(selectedElement, "-1")>0){
			numerotationHelper::lastObjectParentDeleted = "";
			numerotationHelper::lastObjectDeleted = "";
		}
		else{
			numerotationHelper::lastObjectParentDeleted = oid_parent($selectedElement);
			numerotationHelper::lastObjectDeleted = oid_name($selectedElement);
		}
	}
}

Once again, thank you !

View solution in original post

3 REPLIES 3

Hi gbélanger,

Welcome to the PTC Community!

Thank you for your question. 


I’d like to recommend to bring more details and context to your initial inquiry. 

It also helps to have screenshot(s) to better understand what you are trying to do in your process. 

This will increase your chances to receive meaningful help from other Community members. 

 

Regards,

Anurag 

 

Good afternoon, thanks for taking the time to answer me back.  I ended up using the following code:

 

doc_add_callback(current_doc(), 'delete', 'triggerDelete');

...

function triggerDelete(doc, op){
	local tickEvent;
	if($op == 1 && numerotationHelper::insertionInProgress == 0){
		# callback are always called twice
		# https://support.ptc.com/help/arbortext/r8.1.0.0/en/index.html#page/Program/acl_ref/help148-517.html
		numerotationHelper::lastDeletePressed = javascript('d = Date.now();d.toString();');
		local selectedElement = selected_element();
		if(index(selectedElement, "-1")>0){
			numerotationHelper::lastObjectParentDeleted = "";
			numerotationHelper::lastObjectDeleted = "";
		}
		else{
			numerotationHelper::lastObjectParentDeleted = oid_parent($selectedElement);
			numerotationHelper::lastObjectDeleted = oid_name($selectedElement);
		}
	}
}

Once again, thank you !

You can do this using the map command in ACL, something like this:

function myDeleteExtras() {
  # do whatever extra stuff you need here...
  EditDelete; # this executes the normal delete operation
}

map Delete {myDeleteExtras()}
Announcements

Top Tags