Author mode - custom action - insert fragment before caret

Oxygen general issues.
honyk
Posts: 176
Joined: Wed Apr 29, 2009 4:55 pm

Author mode - custom action - insert fragment before caret

Post by honyk »

Hello,

I've tried to make custom action for inserting non-breaking space entity in my DocBook document. I've used default ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation with attribute 'fragment' set to ' '. It places entity, but after caret, not before it. This method offers three placement values, but only if XPath is specified. Can this be used somehow or do I have to write my own plugin? What I need is placing entity before caret so writing can continue without extra cursor moving step.

Jan
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Author mode - custom action - insert fragment before caret

Post by sorin_ristache »

The fragment is inserted at the cursor location. What value did you set for the insertPosition parameter?


Regards,
Sorin
honyk
Posts: 176
Joined: Wed Apr 29, 2009 4:55 pm

Re: Author mode - custom action - insert fragment before caret

Post by honyk »

insertLocation as well as insertPosition are empty. I've also tried insertPosition set to Before, but as it is written in note:
'If the XPath expression is not defined this argument is ignored'.
To tell the truth, it is not very clear if by XPath it is meant insetLocation value or XPath Expression (When this XPath expression is true) from textbox above. Anyway, both are empty in my case.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Author mode - custom action - insert fragment before caret

Post by sorin_ristache »

It is about the insertLocation parameter. If there is no XPath expression set in insertLocation then an insert position relative to a node specified as insert location does not make sense.


Regards,
Sorin
honyk
Posts: 176
Joined: Wed Apr 29, 2009 4:55 pm

Re: Author mode - custom action - insert fragment before caret

Post by honyk »

Thanks, so back to my original question, is there any settings which could be used to insert my fragment ' ' before caret? If XPath is necessary, how to construct it for position somewhere in text? I think self::text() is not sufficient (Oxygen complains 'self::text()' has no result).
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Author mode - custom action - insert fragment before caret

Post by sorin_ristache »

The action for inserting a fragment of text in the Author document just inserts the fragment at the cursor location, that is the cursor is replaced with the inserted fragment and after that the cursor is placed at the end of the fragment. What do you mean before caret? Can you give an example?


Regards,
Sorin
honyk
Posts: 176
Joined: Wed Apr 29, 2009 4:55 pm

Re: Author mode - custom action - insert fragment before caret

Post by honyk »

Ok, one image is better than hundreds of words:
Image
Image
If   fragment is inserted, cursor (caret) is placed into entity, not after fragment, just before Euro sign in this case.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Author mode - custom action - insert fragment before caret

Post by sorin_ristache »

The default action InsertFragmentOperation places the cursor between the two markers. If you want to place the cursor after the markers you can create your own version of InsertFragmentOperation by modifying the original one included in Author SDK and adding a call authorAccess.getEditorAccess().setCaretPosition(). You find the current position with authorAccess.getEditorAccess().getCaretPosition().


Regards,
Sorin
Post Reply