private void SelectNextControlElement(bool forward) { MarkupPointer p; if (forward) { p = EditorContext.Selection.SelectedMarkupRange.End.Clone(); } else { p = EditorContext.Selection.SelectedMarkupRange.Start.Clone(); } IHTMLElement htmlElement = GetNextElement(p, ElementRange, new IHTMLElementFilter(IsSelectableControlElement), forward); if (ContentSourceManager.IsSmartContent(htmlElement)) { SmartContentSelection.SelectIfSmartContentElement(EditorContext, htmlElement); } else if (htmlElement is IHTMLControlElement) { _editor.SelectControlElement((IHTMLControlElement)htmlElement); } if (htmlElement != null) { htmlElement.scrollIntoView(!forward); } }
protected override bool QueryElementSelected() { SmartContentSelection selection = EditorContext.Selection as SmartContentSelection; if (selection != null) { return(selection.HTMLElement.sourceIndex == HTMLElement.sourceIndex); } else { return(false); } }
private void Select() { if (_contentState == SmartContentState.Preserve) { if (HTMLElement != null && HTMLElement.className == HtmlPreserver.PRESERVE_CLASS) { PreserveContentSelection.SelectElement(EditorContext, HTMLElement, _contentState); } } else { SmartContentSelection.SelectIfSmartContentElement(EditorContext, HTMLElement, _contentState); } }
public static SmartContentSelection SelectElement(IHtmlEditorComponentContext editorComponentContext, IHTMLElement e, SmartContentState contentState) { SmartContentSelection selection = (SmartContentSelection)SelectElementCore(editorComponentContext, e, new SmartContentSelection(editorComponentContext, e, contentState)); return(selection); }
/// <summary> /// Navigates the editor's caret to the next editable region. /// </summary> /// <param name="direction"></param> private bool MoveCaretToNextRegion(MOVE_DIRECTION direction) { IHTMLElement nextRegion; _ELEMENT_ADJACENCY nextRegionAdjacency; bool preserveXLocation; if (direction == MOVE_DIRECTION.UP || direction == MOVE_DIRECTION.LEFT) { nextRegion = PreviousEditableRegion; nextRegionAdjacency = _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeEnd; preserveXLocation = direction == MOVE_DIRECTION.UP; } else if (direction == MOVE_DIRECTION.DOWN || direction == MOVE_DIRECTION.RIGHT) { nextRegion = NextEditableRegion; nextRegionAdjacency = _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin; preserveXLocation = direction == MOVE_DIRECTION.DOWN; if (nextRegion == null) { return(false); } MarkupPointer selectRegion = EditorContext.MarkupServices.CreateMarkupPointer(nextRegion, nextRegionAdjacency); MarkupContext mc = selectRegion.Right(false); if (mc.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_EnterScope && mc.Element is IHTMLElement3 && SmartContentSelection.SelectIfSmartContentElement(EditorContext, mc.Element) != null) { return(true); } } else { throw new ArgumentException("Unsupported move direction detected: " + direction); } IDisplayServicesRaw displayServices = (IDisplayServicesRaw)HTMLElement.document; IDisplayPointerRaw displayPointer; displayServices.CreateDisplayPointer(out displayPointer); IHTMLCaretRaw caret = GetCaret(); caret.MoveDisplayPointerToCaret(displayPointer); ILineInfo lineInfo; displayPointer.GetLineInfo(out lineInfo); if (nextRegion != null) { MarkupPointer mp = EditorContext.MarkupServices.CreateMarkupPointer(nextRegion, nextRegionAdjacency); DisplayServices.TraceMoveToMarkupPointer(displayPointer, mp); try { caret.MoveCaretToPointer(displayPointer, true, _CARET_DIRECTION.CARET_DIRECTION_SAME); if (preserveXLocation) { POINT caretLocation; caret.GetLocation(out caretLocation, true); caretLocation.x = lineInfo.x; uint hitTestResults; displayPointer.MoveToPoint(caretLocation, _COORD_SYSTEM.COORD_SYSTEM_GLOBAL, nextRegion, 0, out hitTestResults); caret.MoveCaretToPointer(displayPointer, true, _CARET_DIRECTION.CARET_DIRECTION_SAME); } //BEP: using this line causes scrolling (nextRegion as IHTMLElement2).focus(); (nextRegion as IHTMLElement3).setActive(); return(true); } catch (Exception e) { Debug.Fail("Unexpected exception in MoveCaretToNextRegion: " + e.ToString()); } caret.MoveCaretToPointer(displayPointer, true, _CARET_DIRECTION.CARET_DIRECTION_SAME); } return(false); }