Unify node command

Made a function to unify repeated code for the node command events (click, double click).