The ball operates the arm which closes the valve (cock)
The ball floats till it closes the valve.If the ball is faulty ie has water in it ,the ball will not produce enough pressure on the arm to close the valve fully,therefore water would still get into the tank till it overflows.when you flush the toilet it starts the process again.To test ,at the tank gently lift the arm upwards ,you should have no water running from the valve.If you still have water running it is the valve. best of luck and i'll resist the cock and ball story line