/// <summary> /// Try to keep the selection from including any of the characters in a writing system label. /// See LT-8396. /// </summary> protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew) { base.HandleSelectionChange(prootb, vwselNew); // 1) We don't want to recurse into here. // 2) If the selection is invalid we can't use it. // 3) If the selection is entirely formattable ("IsSelectionInOneFormattableProp"), we don't need to do // anything. if (s_fProcessingSelectionChanged || !vwselNew.IsValid || EditingHelper.IsSelectionInOneFormattableProp()) { return; } try { s_fProcessingSelectionChanged = true; SelectionHelper hlpr = SelectionHelper.Create(vwselNew, this); bool fRange = hlpr.IsRange; bool fChangeRange = false; if (fRange) { bool fAnchorEditable = vwselNew.IsEditable; hlpr.GetIch(SelectionHelper.SelLimitType.Anchor); int tagAnchor = hlpr.GetTextPropId(SelectionHelper.SelLimitType.Anchor); hlpr.GetIch(SelectionHelper.SelLimitType.End); int tagEnd = hlpr.GetTextPropId(SelectionHelper.SelLimitType.End); bool fEndBeforeAnchor = vwselNew.EndBeforeAnchor; if (fEndBeforeAnchor) { if (fAnchorEditable && tagAnchor > 0 && tagEnd < 0) { hlpr.SetTextPropId(SelectionHelper.SelLimitType.End, tagAnchor); hlpr.SetIch(SelectionHelper.SelLimitType.End, 0); fChangeRange = true; } } else { if (!fAnchorEditable && tagAnchor < 0 && tagEnd > 0) { hlpr.SetTextPropId(SelectionHelper.SelLimitType.Anchor, tagEnd); hlpr.SetIch(SelectionHelper.SelLimitType.Anchor, 0); fChangeRange = true; } } } if (fChangeRange) { hlpr.SetSelection(true); } } finally { s_fProcessingSelectionChanged = false; } }
protected override void HandleSelectionChange(IVwRootBox rootb, IVwSelection vwselNew) { CheckDisposed(); base.HandleSelectionChange(rootb, vwselNew); // JohnT: it's remotely possible that the base, in calling commit, made this // selection no longer useable. if (!vwselNew.IsValid) { return; } IWfiWordform wordform; if (!GetSelectedWordform(vwselNew, out wordform)) { wordform = null; } m_mediator.PropertyTable.SetProperty("TextSelectedWord", wordform); m_mediator.PropertyTable.SetPropertyPersistence("TextSelectedWord", false); SelectionHelper helper = SelectionHelper.Create(vwselNew, this); if (helper != null && helper.GetTextPropId(SelectionHelper.SelLimitType.Anchor) == RawTextVc.kTagUserPrompt) { vwselNew.ExtendToStringBoundaries(); EditingHelper.SetKeyboardForSelection(vwselNew); } }
protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit) { if (sel == null) { return(-1); } int tag = sel.GetTextPropId(limit); if (tag == AffixRuleFormulaVc.ktagLeftEmpty || tag == AffixRuleFormulaVc.ktagRightEmpty || tag == MoAffixProcessTags.kflidOutput) { return(tag); } foreach (SelLevInfo level in sel.GetLevelInfo(limit)) { if (level.tag == MoAffixProcessTags.kflidOutput) { return(level.tag); } if (level.tag == MoAffixProcessTags.kflidInput) { return(level.hvo); } } return(-1); }
protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit) { int tag = sel.GetTextPropId(limit); switch (tag) { case MetaRuleFormulaVc.ktagLeftEnv: return(PhMetathesisRuleTags.kidxLeftEnv); case MetaRuleFormulaVc.ktagLeftSwitch: return(PhMetathesisRuleTags.kidxLeftSwitch); case MetaRuleFormulaVc.ktagRightSwitch: return(PhMetathesisRuleTags.kidxRightSwitch); case MetaRuleFormulaVc.ktagRightEnv: return(PhMetathesisRuleTags.kidxRightEnv); } var obj = GetItem(sel, limit); if (obj == null) { return(-1); } return(Rule.GetStrucChangeIndex(obj as IPhSimpleContext)); }
protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit) { int tag = sel.GetTextPropId(limit); switch (tag) { case MetaRuleFormulaVc.ktagLeftEnv: return(PhMetathesisRule.kidxLeftEnv); case MetaRuleFormulaVc.ktagLeftSwitch: return(PhMetathesisRule.kidxLeftSwitch); case MetaRuleFormulaVc.ktagRightSwitch: return(PhMetathesisRule.kidxRightSwitch); case MetaRuleFormulaVc.ktagRightEnv: return(PhMetathesisRule.kidxRightEnv); } int hvo = GetItemHvo(sel, limit); if (hvo == 0) { return(-1); } return(Rule.GetStrucChangeIndex(hvo)); }
protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit) { if (sel == null) { return(-1); } foreach (SelLevInfo level in sel.GetLevelInfo(limit)) { if (IsCellFlid(level.tag)) { return(level.tag); } } if (IsCellFlid(sel.GetTextPropId(limit))) { return(sel.GetTextPropId(limit)); } return(-1); }
public override void SelectionChanged(IVwRootBox rootb, IVwSelection vwselNew) { CheckDisposed(); base.SelectionChanged(rootb, vwselNew); // JohnT: it's remotely possible that the base, in calling commit, made this // selection no longer useable. if (!vwselNew.IsValid) { return; } SelectionHelper helper = SelectionHelper.Create(vwselNew, this); if (helper != null && helper.GetTextPropId(SelectionHelper.SelLimitType.Anchor) == RawTextVc.kTagUserPrompt) { vwselNew.ExtendToStringBoundaries(); EditingHelper.SetKeyboardForSelection(vwselNew); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// Call MouseUp on the rootbox /// </summary> /// ----------------------------------------------------------------------------------- protected override void CallMouseUp(Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot) { IVwSelection sel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false); ScrScriptureNote ann = CurrentAnnotation; ScrScriptureNote.ScrScriptureNoteTags noteTagToSelect = ScrScriptureNote.ScrScriptureNoteTags.kflidDiscussion; bool fMakeSelInFirstResponse = false; if (sel != null && sel.SelType == VwSelType.kstPicture) { SelectionHelper selHelper = SelectionHelper.Create(sel, this); SelLevInfo[] info = selHelper.LevelInfo; if (info.Length >= 1 && info[0].tag == (int)ScrScriptureNote.ScrScriptureNoteTags.kflidDiscussion || info[0].tag == (int)ScrScriptureNote.ScrScriptureNoteTags.kflidRecommendation || m_fdoCache.GetClassOfObject(info[0].hvo) == StJournalText.kClassId) { bool fExpanding = m_vc.ToggleItemExpansion(info[0].hvo, m_rootb); if (fExpanding) { // If the tag is not a valid tag, the assumption // is we're expanding the responses. fMakeSelInFirstResponse = (info[0].tag < 0); noteTagToSelect = (ScrScriptureNote.ScrScriptureNoteTags)info[0].tag; } } else if (selHelper.GetTextPropId(SelectionHelper.SelLimitType.Anchor) == -(int)NotesFrags.kfrConnotCategory) // This is not a real flid, just a unique number to match on. { SetAnnotationCategory(ann); } else if (info.Length >= 2 && info[1].tag == m_currentNotesTag) { m_ignoreSelChanged = !m_vc.ToggleItemExpansion(info[1].hvo, m_rootb); } } base.CallMouseUp(pt, rcSrcRoot, rcDstRoot); m_ignoreSelChanged = false; if (!m_pictureSelected) { return; } m_pictureSelected = false; if (ann == null || m_vc.NotesSequenceHandler == null) { return; } // Make a selection in the proper place in the annotation. int book = BCVRef.GetBookFromBcv(ann.BeginRef) - 1; ScrBookAnnotations annotations = (ScrBookAnnotations)m_scr.BookAnnotationsOS[book]; int index = m_vc.NotesSequenceHandler.GetVirtualIndex(annotations.Hvo, ann.IndexInOwner); if (fMakeSelInFirstResponse) { NotesEditingHelper.MakeSelectionInNote(book, index, 0, ScrScriptureNote.ScrScriptureNoteTags.kflidResponses); } else if (m_vc.IsExpanded(ann.Hvo) && m_vc.IsExpanded(Cache.GetObjProperty(ann.Hvo, (int)noteTagToSelect))) { NotesEditingHelper.MakeSelectionInNote(m_vc, false, book, index, 0, noteTagToSelect, this, true); } else { NotesEditingHelper.MakeSelectionInNoteRef(m_vc, book, index, this); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// Call MouseUp on the rootbox /// </summary> /// ----------------------------------------------------------------------------------- protected override void CallMouseUp(Point pt, Rectangle rcSrcRoot, Rectangle rcDstRoot) { IVwSelection sel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false); IScrScriptureNote ann = CurrentAnnotation; int noteTagToSelect = ScrScriptureNoteTags.kflidDiscussion; bool fMakeSelInFirstResponse = false; if (sel != null && sel.SelType == VwSelType.kstPicture) { SelectionHelper selHelper = SelectionHelper.Create(sel, this); SelLevInfo[] info = selHelper.LevelInfo; if (info.Length >= 1 && info[0].tag == ScrScriptureNoteTags.kflidDiscussion || info[0].tag == ScrScriptureNoteTags.kflidRecommendation || m_fdoCache.ServiceLocator.ObjectRepository.GetClsid(info[0].hvo) == StJournalTextTags.kClassId) { if (m_vc.ToggleItemExpansion(info[0].hvo, m_rootb)) { // If the tag is not a valid tag, the assumption // is we're expanding the responses. fMakeSelInFirstResponse = (info[0].tag < 0); noteTagToSelect = info[0].tag; } } else if (selHelper.GetTextPropId(SelectionHelper.SelLimitType.Anchor) == -(int)NotesFrags.kfrConnotCategory) // This is not a real flid, just a unique number to match on. { SetAnnotationCategory(ann); } else if (info.Length >= 2 && info[1].tag == kCurrentNotesTag) { m_vc.ToggleItemExpansion(info[1].hvo, m_rootb); m_ignoreSelChanged = true; } } m_suspendHighlightChange = true; try { base.CallMouseUp(pt, rcSrcRoot, rcDstRoot); } finally { m_ignoreSelChanged = false; m_suspendHighlightChange = false; } UpdateNoteHighlight(ann); if (!m_pictureSelected) { return; } m_pictureSelected = false; if (ann == null) { return; } // Make a selection in the proper place in the annotation. int book = BCVRef.GetBookFromBcv(ann.BeginRef) - 1; IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[book]; int index = m_rootb.DataAccess.GetObjIndex(annotations.Hvo, ScrBookAnnotationsTags.kflidNotes, ann.Hvo); if (fMakeSelInFirstResponse) { NotesEditingHelper.MakeSelectionInNote(book, index, 0, ScrScriptureNoteTags.kflidResponses); } else if (m_vc.IsExpanded(ann.Hvo) && m_vc.IsExpanded(m_rootb.DataAccess.get_ObjectProp(ann.Hvo, noteTagToSelect))) { NotesEditingHelper.MakeSelectionInNote(m_vc, false, book, index, 0, noteTagToSelect, this, true); } else { NotesEditingHelper.MakeSelectionInNoteRef(m_vc, book, index, this); } }