Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it OK to set start and end text nodes for Range object in Java?
    primarykey
    data
    text
    <p>I need to determine whether the cursor is within XML range. I've set start and end text nodes for Range. I suppose that compareBoundaryPoints method does not work properly for this case. Surely, I can be wrong. In Java I use <code>com.arbortext.epic.ADocument</code>, <code>org.w3c.dom.ranges.Range</code> imports. <code>holeRange_</code> is a <code>org.w3c.dom.ranges.Range</code> object.</p> <pre><code>holeRange_ = ((DocumentRange) txtProcessor_.GetDocument()).createRange(); holeRange_.setStart(startNode, 0); //text node holeRange_.setEndAfter(endNode); //text node </code></pre> <p>Here is the body of click event handler:</p> <pre><code>Range caretRange = ((ADocument) txtProcessor_.GetDocument()).getInsertionPoint(); if (caretRange != null) { DebugMode.println(caretRange.getStartContainer().getNodeValue()); DebugMode.println("END_TO_START = " + textNodeRange_.compareBoundaryPoints(Range.END_TO_START, caretRange)); DebugMode.println("START_TO_END = " + holeRange_.compareBoundaryPoints(Range.START_TO_END, caretRange)); } </code></pre> <p>The output gives END_TO_START = -1 and START_TO_END = -1 when the cursor is inside the range. According to <a href="https://stackoverflow.com/questions/9324654/check-if-specified-element-is-inside-selection">Check if specified element is inside selection</a> the values should be: END_TO_START = -1 and START_TO_END = 1. Is the problem linked with it: <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=148126" rel="nofollow noreferrer">https://bugs.eclipse.org/bugs/show_bug.cgi?id=148126</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload