Select all content in a particular nodeview

I have implemented a custom nodeview and I want to restrict the select all ( cmd+A ) to the current nodeview. e.g If I press cmd+A in a table cell, only the content in the table cell should be selected. What would be the best way to achieve this?

Write a command that checks if the selection is in such a node and creates the appropriate selection (and returns true) when it is. Then bind this to ctrl/cmd-a with a higher precedence than the default binding.

Thank you @marijn