Extract all onclick behaviour into handler

This allows more flexibility for a custom handler to override the node
onclick event.