Fix crash when using right mouse button