Safety check in mouse events.

Sometimes moving the mouse just after refreshing caused an error.