Add mouse callback funcs and fix some bugs.