public static IHTMLElement GetSelectedChildEditField(IHTMLElement parent, MarkupRange selection) { if (selection == null || !selection.Positioned) { Trace.Fail("Selection is invalid!"); return(null); } IHTMLElement element = selection.ParentElement(); if (element == null || !HTMLElementHelper.IsChildOrSameElement(parent, element)) { return(null); } do { if (InlineEditField.IsEditField(element)) { return(element); } element = element.parentElement; } while (element != null && element.sourceIndex != parent.sourceIndex); return(null); }
protected override int HandlePreHandleEvent(int inEvtDispId, IHTMLEventObj pIEventObj) { if (ShouldProcessEvents(inEvtDispId, pIEventObj)) { if (inEvtDispId == DISPID_HTMLELEMENTEVENTS2.ONMOUSEDOWN) { leftMouseDown = (Control.MouseButtons & MouseButtons.Left) == MouseButtons.Left; if (!Selected && HTMLElementHelper.IsChildOrSameElement(HTMLElement, pIEventObj.srcElement)) { return(HandlePreHandleEventLeftMouseButtonDown(inEvtDispId, pIEventObj)); } rightMouseDown = (Control.MouseButtons & MouseButtons.Right) == MouseButtons.Right; if (rightMouseDown) { //cancel the event so that the editor doesn't try to do a right drag drop //we'll handle showing the context menu on our own. return(HRESULT.S_OK); } } int controlResult = base.HandlePreHandleEvent(inEvtDispId, pIEventObj); UpdateCursor(Selected, inEvtDispId, pIEventObj); if (_resizerControl.Mode == SizerMode.Resizing) { //if the control is resizing, kill all events so that the editor doesn't //try to do a drag and drop. return(HRESULT.S_OK); } else { if (_dragDropController.PreHandleEvent(inEvtDispId, pIEventObj) == HRESULT.S_OK) { return(HRESULT.S_OK); } //eat the mouse events so that the editor doesn't try to //do anything funny (like opening a browser URL). //Note: Allow non-left clicks through for right-click context menus switch (inEvtDispId) { case DISPID_HTMLELEMENTEVENTS2.ONMOUSEUP: if (rightMouseDown & (Control.MouseButtons & MouseButtons.Right) != MouseButtons.Right) { rightMouseDown = false; Point p = EditorContext.PointToScreen(new Point(pIEventObj.clientX, pIEventObj.clientY)); EditorContext.ShowContextMenu(p); return(HRESULT.S_OK); } return(leftMouseDown ? HRESULT.S_OK : HRESULT.S_FALSE); } } return(controlResult); } return(HRESULT.S_FALSE); }