{"record":{"id":"65c9235df527a0ca","repo":"stride3d/stride","slug":"internal-error-can-not-activate-edit-text-another-edit-text","errorCode":null,"errorMessage":"Internal error: Can not activate edit text, another edit text is already active","messagePattern":"Internal error: Can not activate edit text, another edit text is already active","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.UI/Controls/EditText.Android.cs","lineNumber":240,"sourceCode":"                return;\n\n            editText.Post(editTextSetMaxLinesAction);\n        }\n\n        private void OnMinLinesChangedImpl()\n        {\n            if (editText == null)\n                return;\n\n            editText.Post(editTextSetMinLinesAction);\n        }\n\n        private void ActivateEditTextImpl(InputManager inputManager)\n        {\n            lock (syncRoot)\n            {\n                if (activeEditText is not null)\n                    throw new Exception(\"Internal error: Can not activate edit text, another edit text is already active\");\n\n                EnsureStaticEditText();\n                if (staticEditText is null)\n                    return;  // headless test environment — no native popup means no activation\n\n                activeEditText = this;\n\n                // Select all text on initial focus.\n                // TODO: Maybe make it configurable on how caret/selection should default on activation?\n                SelectAll();\n                // Note that we do not assign 'staticEditText' to 'editText' until the Post action\n                // is actually invoked to ensure the control is fully ready\n                staticEditText.Post(editTextSetActivatedStateAction);\n\n                GetGameContext()?.ShowEditTextPopup();\n            }\n        }\n","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.UI/Controls/EditText.Android.cs#L222-L258","documentation":"This error is thrown by Stride.UI's Android EditText backing store when a second native edit text is about to be activated while one is already active. The class keeps a single static/active native EditText popup per process, so only one control may hold it at a time. It signals an internal state-machine violation in UI focus management rather than a caller mistake.","triggerScenarios":"Calling ActivateEditTextImpl (directly or via focus/selection APIs such as IsSelectionActive touching selection activation) while activeEditText is already set to another control; activating two EditTexts without deactivating the first; a prior EditText failing to release the native popup during deactivation.","commonSituations":"Programmatically focusing a second text input while a first still has focus on Android; UI layouts where focus transitions skip the deactivate step; headless or automated test harnesses where native popup teardown behaves differently.","solutions":["Ensure the currently active EditText is deactivated (focus lost / selection cleared) before activating another one","Only programmatically activate an EditText when IsSelectionActive is false","Check for leaked activation: if the first EditText was removed from the tree while active, deactivate or dispose it first","Reproduce with a minimal two-EditText focus script and report as a Stride bug if the framework leaves activeEditText set"],"exampleFix":"// before\neditTextA.ActivateFocus();\neditTextB.ActivateFocus(); // throws: A still active\n// after\neditTextA.DeactivateFocus(); // or move focus away first\neditTextB.ActivateFocus();","handlingStrategy":"try-catch","validationCode":"if (activeEditText != null && activeEditText != myEditText)\n    activeEditText.DeactivateFocus(); // release native popup first","typeGuard":"bool CanActivate(EditText e) => e != null && !e.IsSelectionActive;","tryCatchPattern":"try\n{\n    editText.ActivateFocus();\n}\ncatch (Exception ex) when (ex.Message.Contains(\"another edit text is already active\"))\n{\n    // deactivate the other EditText and retry once, or log a focus-management bug\n}","preventionTips":["Never activate two EditTexts concurrently; route all programmatic focus through one helper","Deactivate/dispose removed EditTexts to avoid leaked activations","In tests, reset focus state between cases"],"tags":["android","ui","focus","edittext"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}