It is more likely the mouse will be inside the polygon than on the line, could move this before the polyline check.