From 3fdca2beef1aa85c0c998fbc4b097b1cba418793 Mon Sep 17 00:00:00 2001 From: Jake Oliver Date: Fri, 26 Apr 2024 18:56:43 -0400 Subject: [PATCH] LT-20853: Fix FocusBox word bundle elements' order (#31) * Dispose and recreate the FocusBoxController if the writing system has changed --- Src/LexText/Interlinear/InterlinDocForAnalysis.cs | 12 ++++++++++-- Src/LexText/Interlinear/SandboxBase.cs | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs index dd66ac1729..8cd44701cf 100644 --- a/Src/LexText/Interlinear/InterlinDocForAnalysis.cs +++ b/Src/LexText/Interlinear/InterlinDocForAnalysis.cs @@ -304,7 +304,7 @@ public virtual void TriggerAnalysisSelected(AnalysisOccurrence target, bool fSav MoveFocusBoxIntoPlace(); // Now it is the right size and place we can show it. TryShowFocusBox(); - // All this CAN hapen because we're editing in another window...for example, + // All this CAN happen because we're editing in another window...for example, // if we edit something that deletes the current wordform in a concordance view. // In that case we don't want to steal the focus. if (ParentForm == Form.ActiveForm) @@ -1828,6 +1828,8 @@ internal override void UpdateForNewLineChoices(InterlinLineChoices newChoices) } } + private bool previousRightToLeft; + private bool hasRightToLeftChanged => previousRightToLeft != Vc.RightToLeft; /// /// returns the focus box for the interlinDoc if it exists or can be created. /// @@ -1835,9 +1837,10 @@ internal FocusBoxController FocusBox { get { - if (ExistingFocusBox == null && ForEditing) + if ((ExistingFocusBox == null && ForEditing) || hasRightToLeftChanged) { CreateFocusBox(); + previousRightToLeft = Vc.RightToLeft; } return ExistingFocusBox; } @@ -1849,6 +1852,11 @@ internal FocusBoxController FocusBox internal override void CreateFocusBox() { + if (ExistingFocusBox != null) + { + ExistingFocusBox.Dispose(); + } + ExistingFocusBox = CreateFocusBoxInternal(); } diff --git a/Src/LexText/Interlinear/SandboxBase.cs b/Src/LexText/Interlinear/SandboxBase.cs index e866a8e9cc..7e4f10cf53 100644 --- a/Src/LexText/Interlinear/SandboxBase.cs +++ b/Src/LexText/Interlinear/SandboxBase.cs @@ -3873,10 +3873,10 @@ public override void MakeRoot() m_dxdLayoutWidth = kForceLayout; // Don't try to draw until we get OnSize and do layout. // For some reason, we don't always initialize our control size to be the same as our rootbox. - this.Margin = new Padding(3, 0, 3, 1); + Margin = new Padding(3, 0, 3, 1); SyncControlSizeToRootBoxSize(); if (RightToLeftWritingSystem) - this.Anchor = AnchorStyles.Right | AnchorStyles.Top; + Anchor = AnchorStyles.Right | AnchorStyles.Top; //TODO: //ptmw->RegisterRootBox(qrootb);