The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
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.
Solved! Go to Solution.
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 !
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()}