Exemple #1
0
		private void DisposeComboHandler()
		{
			if (m_ComboHandler != null)
			{
				(m_ComboHandler as IDisposable).Dispose();
				m_ComboHandler = null;
			}
		}
Exemple #2
0
		/// <summary>
		/// Make a combo box appropriate for the specified selection. If fMouseDown is true,
		/// do so unconditionally...otherwise (mousemove) only if the new selection is on a different thing.
		/// </summary>
		/// <param name="vwselNew"></param>
		/// <param name="fForce"></param>
		private void ShowComboForSelection(IVwSelection vwselNew, bool fMouseDown)
		{
			// It's a good idea to get this first...it's possible for MakeCombo to leave the selection invalid.
			SIL.Utils.Rect loc;
			vwselNew.GetParaLocation(out loc);
			if (!fMouseDown)
			{
				// It's a mouse move.
				// If we've moved to somewhere outside any paragraph get rid of the combos.
				// But, allow somewhere close, since otherwise it's almost impossible to get
				// a combo on an empty string.
				SIL.Utils.Rect locExpanded = loc;
				locExpanded.right += 50;
				locExpanded.left -= 5;
				locExpanded.top -= 2;
				locExpanded.bottom += 2;
				if (!locExpanded.Contains(m_LastMouseMovePos))
				{
					HideCombos();
					return;
				}
				// Don't do anything if the current mouse position is in the same paragraph
				// as before. Things tend to flicker if we continually create and remove it.
				// But, if we've hidden all the combos, go ahead even if at the same position as before...
				// otherwise, when we drag off outside the text and return, we may not get any combo.
				if (loc.Equals(m_locLastShowCombo) && FirstLineHandler != null)
				{
					return;
				}
			}
			FinishUpOk(); // Just like OK, if there are pending edits in the combo, do them.
			// Changing a different item may result in changes to this one also. This could invalidate
			// the selection, in which case, we can't use it.
			// Enhance JohnT: might consider trying the current selection, if any, if called from
			// MouseDown...that would not be useful if called from hover. But there probably isn't
			// a current selection in that case. Could try a selection at the saved mouse position.
			if (!vwselNew.IsValid)
				return;

			m_locLastShowCombo = loc;

			m_fMakingCombo = true;
			HideCombos();
			// No matter what, we are fixin to get rid of the old value.
			DisposeComboHandler();
			if (!m_fInMouseDrag)
			{
				m_ComboHandler = InterlinComboHandler.MakeCombo(m_mediator.HelpTopicProvider,
					vwselNew, this, fMouseDown);
			}
			else
			{
				m_ComboHandler = null;
			}
			m_fMakingCombo = false;
			m_fLockCombo = false; // nothing typed in it yet.
			if (m_ComboHandler != null)
			{
				// Set the position of the combo and display it. Do this before synchronizing
				// the LexEntry display, which can take a while.
				m_ComboHandler.Activate(loc);
				m_fMouseDownActivatedCombo = true;
				// If the selection moved to a different morpheme, and we know a corresponding
				// LexEntry, switch to it.
				if (m_ComboHandler.SelectedMorphHvo != 0)
				{
					int hvoSbEntry = m_caches.DataAccess.get_ObjectProp(
						m_ComboHandler.SelectedMorphHvo, ktagSbMorphEntry);
					if (hvoSbEntry != 0)
					{
						//SetSelectedEntry(m_caches.RealHvo(hvoSbEntry)); // seems to be buggy.
					}
				}
			}
		}