cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Absolute Offset of Selected Text

WM_11018447
3-Visitor

Absolute Offset of Selected Text

We are currently using Arbortext 8.2 and would like to know how we can get the absolute offset (starting from the top of the document) of selected/highlighted text. We have tried looking into the ACL commands and have not found any.

Any help with how to achieve this will be highly appreciated.

Thanks,

Willy.

5 REPLIES 5

Arbortext implements what is known as the Arbortext Object Model (AOM) which is actually a superset of DOM Level 2. The idea is you use the AOM methods to work with your document. For example, the ADocument interface provides a textSelection attribute to get the DOM Range for the user's cursor selection: https://support.ptc.com/help/arbortext/r8.2.1.0/en/index.html#page/Program/programmer_ref/adocument_textselection.html

 

Using the returned Range you can then find out startOffset, endOffset, etc.

 

I'm not sure if that's exactly what you're after but hopefully puts you on the right path.

I have tried using this but it's not what we want. It returns the offset of the selected text in the current element. In our case, we need to get the start and end offset of the text in the context of the whole document.


I would like to ask if there is any we can get the XPath of the element with selected text.

Oh in that case I'm not sure the AOM methods will suit. You can explore ACL methods oid_offset, oid_caret_pos, and oid_caret_offset.

For calculating XPath of the selected text that is not available as an Arbortext method but you could write your own function to do that using the oid_*

methods.

I am curious what you are trying to achieve as there may be an alternative or better way to implement the functionality.

Hello Gareth, 
Thank you for the response. The solutions provided did not help solve my issue. I was hoping that there was a way to get the absolute offset of content that is selected.

I'm sorry to hear you are still struggling with that. My only other idea would be to review the ACL files that ship with Arbortext Editor. They often contain useful code snippets such as what you're after here.

If your needs are critical then there are Arbortext specialists who can help with matters like this. If you are interested in a quote for such services then feel free to reach out to us here at GPSL (www.gpsl.co).

Top Tags