Replaces getSelectionCoordinates with Tim Down's implementation