Fix incorrect paints when paint events generated by mouse clicks