/// <summary> /// If we are in ReadOnlySelect mode, intercept the click, and select the appropriate row /// without installing a normal selection. /// </summary> /// <param name="e"></param> protected override void OnMouseUp(MouseEventArgs e) { //If XmlBrouseView did not receive a mouse down event then we do not want to //do anything on the mouseUp because the mouseUp would have come from clicking //somewhere else. LT-8939 if (!m_fMouseUpEnabled) { return; } try { if (m_selectedIndex == -1) { return; // Can't do much in an empty list, so quit. } m_fHandlingMouseUp = true; #pragma warning disable 219 int oldSelectedIndex = m_selectedIndex; #pragma warning restore 219 // Note all the stuff we might want to know about what was clicked that we will // use later. We want to get this now before anything changes, because there can // be scrolling effects from converting dummy objects to real. IVwSelection vwsel = MakeSelectionAt(e); int newSelectedIndex = GetRowIndexFromSelection(vwsel, true); // If we're changing records, we need to do some tricks to keep the selection in the place // clicked and the focus here. Save the information we will need. SelectionHelper clickSel = null; if (newSelectedIndex != SelectedIndex && vwsel != null && SelectionHelper.IsEditable(vwsel)) { clickSel = SelectionHelper.Create(vwsel, this); } ITsString tssWord = null; // word clicked for click copy ITsString tssSource = null; // whole source string of clicked cell for click copy int hvoNewSelRow = 0; // hvo of new selected row (only for click copy) int ichStart = 0; // of tssWord in tssSource if (ClickCopy != null && e.Button == MouseButtons.Left && newSelectedIndex >= 0) { if (vwsel != null && vwsel.SelType == VwSelType.kstText) { int icol = vwsel.get_BoxIndex(false, 3); if (icol != Vc.OverrideAllowEditColumn + 1) { IVwSelection vwSelWord = vwsel.GrowToWord(); // GrowToWord() can return a null -- see LT-9163 and LT-9349. if (vwSelWord != null) { vwSelWord.GetSelectionString(out tssWord, " "); tssWord = StripTrailingNewLine(tssWord); hvoNewSelRow = m_sda.get_VecItem(m_hvoRoot, m_fakeFlid, newSelectedIndex); int hvoObj, tag, ws; bool fAssocPrev; vwSelWord.TextSelInfo(false, out tssSource, out ichStart, out fAssocPrev, out hvoObj, out tag, out ws); } } } } // We need to manually change the index for ReadOnly views. // SimpleRootSite delegates RightMouseClickEvent to our RecordBrowseView parent, // which also makes the selection for us.. if (ReadOnlySelect && e.Button != MouseButtons.Right) { if (this.m_xbvvc.HasSelectColumn && e.X < m_xbvvc.SelectColumnWidth) { base.OnMouseUp(e); // allows check box to operate. } } else { // If we leave this set, the base method call's side effects like updating the WS combo // don't happen. m_fHandlingMouseUp = false; base.OnMouseUp(e); // normal behavior. m_fHandlingMouseUp = true; } SetSelectedIndex(newSelectedIndex); if (tssWord != null) { // We're doing click copies; generate an event. // Do this AFTER other actions which may change the current line. ClickCopy(this, new ClickCopyEventArgs(tssWord, hvoNewSelRow, tssSource, ichStart)); } if (clickSel != null) { IVwSelection finalSel = null; // There seem to be some cases where the selection helper can't restore the selection. // One that came up in FWR-3666 was clicking on a check box. // If we can't re-establish an editiable selection just let the default behavior continue. try { finalSel = clickSel.MakeRangeSelection(RootBox, false); } catch (Exception) { } if (finalSel != null && SelectionHelper.IsEditable(finalSel)) { finalSel.Install(); FocusMe(); } } } finally { m_fHandlingMouseUp = false; m_fMouseUpEnabled = false; } }