void Console::SetVisible(bool enable) { Input* input = GetSubsystem<Input>(); background_->SetVisible(enable); closeButton_->SetVisible(enable); if (enable) { // Check if we have receivers for E_CONSOLECOMMAND every time here in case the handler is being added later dynamically bool hasInterpreter = PopulateInterpreter(); commandLine_->SetVisible(hasInterpreter); if (hasInterpreter && focusOnShow_) GetSubsystem<UI>()->SetFocusElement(lineEdit_); // Ensure the background has no empty space when shown without the lineedit background_->SetHeight(background_->GetMinHeight()); // Show OS mouse input->SetMouseVisible(true, true); } else { rowContainer_->SetFocus(false); interpreters_->SetFocus(false); lineEdit_->SetFocus(false); // Restore OS mouse visibility input->ResetMouseVisible(); } }
void InGameEditor::SetVisible(bool enable) { if (enable != rootUI_->IsVisible()) { Input* input = GetSubsystem<Input>(); rootUI_->SetVisible(enable); if (enable) { // Show OS mouse input->SetMouseVisible(true, true); using namespace StartInGameEditor; VariantMap& newEventData = GetEventDataMap(); SendEvent(E_START_INGAMEEDITOR_, newEventData); /// Subscribe input events SubscribeToEvent(E_KEYDOWN, URHO3D_HANDLER(InGameEditor, HandleKeyDown)); SubscribeToEvent(E_KEYUP, URHO3D_HANDLER(InGameEditor, HandleKeyUp)); // Subscribe HandleUpdate() function for processing update events SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(InGameEditor, HandleUpdate)); SetMainEditor(PluginScene3DEditor::GetTypeStatic()); } else { // Restore OS mouse visibility input->ResetMouseVisible(); ui_->SetFocusElement(NULL); using namespace QuitInGameEditor; VariantMap& newEventData = GetEventDataMap(); SendEvent(E_QUIT_INGAMEEDITOR_, newEventData); /// Subscribe input events UnsubscribeFromEvent(E_KEYDOWN); UnsubscribeFromEvent(E_KEYUP); UnsubscribeFromEvent(E_UPDATE); if (mainEditorPlugin_) { // mainEditorPlugin_->Leave(); } } } }