Page 1 of 1

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

Posted: Wed Sep 04, 2013 11:10 am
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

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

Posted: Wed Sep 04, 2013 11:25 am
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

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

Posted: Wed Sep 04, 2013 11:45 am
by yann1806
Works beautifully - and yes of course, makes sense that there can still be attributes.

Thanks,

Yann