How do I make the mouse move in steps of some pixels so that it moves only over the grid drawn on the picture?