Action that inserts a tag and moves the cursor to after that

Oxygen general issues.
yann1806
Posts: 22
Joined: Fri Aug 09, 2013 11:03 am

Action that inserts a tag and moves the cursor to after that

Post by yann1806 »

Hi guys,

I want to write an InsertFragmentOperation action that inserts "<br/>" and moves the cursor to after that new "<br/>" tag; the tag in the schema is declared so that it doesn't allow any text inside.

In my Author / Action tab, I do have goToNextEditablePosition to true for my action, but the editor still positions the cursor inside the <br/> tag, which forces me to click "right-arrow" to continue typing after inserting a line break.

I saw a very old message saying one has to write a custom action for something like that, is it still true?

Thanks

Yann
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: Action that inserts a tag and moves the cursor to after

Post by Radu »

Hi Yan,

When you set the XML fragment to be inserted in the action, you can also use different code templates for it (there is a small drop-down button to the right of the edit area).
So you can set an XML fragment like:

Code: Select all

<br/>${caret}
which will force the caret to be after the element.
Indeed empty elements do not have text content but they still have attributes which can be set on them. So maybe the user wants to insert the empty element and then use the Attributes view to edit some attributes on it, that's why the caret is placed inside it by default.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
yann1806
Posts: 22
Joined: Fri Aug 09, 2013 11:03 am

Re: Action that inserts a tag and moves the cursor to after

Post by yann1806 »

Works beautifully - and yes of course, makes sense that there can still be attributes.

Thanks,

Yann
Post Reply