Is there a way pickup highlighted words?

Post here questions and problems related to oXygen frameworks/document types.
wbrisett
Posts: 38
Joined: Thu Feb 21, 2013 11:44 pm

Is there a way pickup highlighted words?

Post by wbrisett »

I'm putting together a set of toolbar shortcuts. I want to be able to do this:

Sample text:
"All look your best," Peter warned them; "first impressions are awfully important."

If I highlight the word 'impressions', I want to see this:

"All look your best," Peter warned them; "first <term keyref="impressions">impressions</term> are awfully important."

I have a custom framework where I've used the wrap element, but it's getting the attribute set that I can't seem to figure out. I'm sure I'm just overlooking something simple. But I don't see anything in the documentation either.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a way pickup highlighted words?

Post by Radu »

Hi Wayne,

What do you mean by "I've used the wrap element"? Can you give me some sample code about how you attempt to do this in the custom framework?
For example if I used the AuthorDocumentController API from the Java code I would do something like:

Code: Select all


if(authorAccess.getEditorAccess().hasSelection()){
AuthorDocumentFragment frag = authorAccess.getDocumentController().createNewDocumentFragmentInContext("<term keyref='impressions'/>", authorAccess.getEditorAccess().getCaretOffset());
authorAccess.getDocumentController().surroundInFragment(frag, authorAccess.getEditorAccess().getSelectionStart(), authorAccess.getEditorAccess().getSelectionEnd() - 1);
}
https://www.oxygenxml.com/InstData/Edit ... oller.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
wbrisett
Posts: 38
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett »

In the Document Type Association panel, I've added an extension of the DITA framework, in that I've created an action for a custom toolbar item.

I've added the operation of :

ToggleSurroundWithElementOperation

In the Argument Value, it has:

Name: Element
Type: Fragment

It's in this value dialog I was hoping there was something I could do that would enable me to to not only place the <term keyref=""></term>, but actually pickup the word highlighted and place it in the attribute string. Is that possible, or do I need a different approach?
wbrisett
Posts: 38
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett »

Here is where I am doing things Radu:
https://www.oxygenxml.com/doc/versions/ ... ialog.html
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a way pickup highlighted words?

Post by Radu »

Hi,

You can use the ${selection} editor variable in the value you set for the "element" parameter of the operation like:

Code: Select all

<term  keyref="${selection}"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
wbrisett
Posts: 38
Joined: Thu Feb 21, 2013 11:44 pm

Re: Is there a way pickup highlighted words?

Post by wbrisett »

I was close... I had $1, but that wasn't working. Thanks Radu!
Post Reply