- // Connect signals
- windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
- windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
- windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
- windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
- windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
- windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent );
- windowBase->SelectionDataSendSignal().Connect( this, &EventHandler::OnSelectionDataSend );
- windowBase->SelectionDataReceivedSignal().Connect( this, &EventHandler::OnSelectionDataReceived );
- windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged );
- windowBase->AccessibilitySignal().Connect( this, &EventHandler::OnAccessibilityNotification );
+ if( surface )
+ {
+ WindowBase* windowBase = surface->GetWindowBase();
+
+ // Connect signals
+ windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
+ windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
+ windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
+ windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
+ windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
+ windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent );
+ windowBase->SelectionDataSendSignal().Connect( this, &EventHandler::OnSelectionDataSend );
+ windowBase->SelectionDataReceivedSignal().Connect( this, &EventHandler::OnSelectionDataReceived );
+ windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged );
+ windowBase->AccessibilitySignal().Connect( this, &EventHandler::OnAccessibilityNotification );
+ }