Mouse events functions refactoring.