Fix a crash bug in BeforeRun()

The mouse update function uses a _form field before it is initialized, causing a NRE. This PR add a check and returns early without crashing.