On 11/17/2011 05:15 AM, Carlos Villegas wrote:
>
> I'm writing a custom view Swing component for v4.9.1 that is not focusable.
> I added a mouse click listener to set the selected element like this:
>
>        NodeMark selected = markManager.getSelected();
>        if (selected == null || selected.getNode() != element) {
>                 markManager.beginMark();
>
>                 markManager.remove(Mark.SELECTED2);
>                 markManager.remove(Mark.MARK);
>                 markManager.set(Mark.SELECTED, element);
>                 //docView.ensureDotIsInside(element);
>                 TextNode text =
>                                   (TextNode)
> Traversal.traverseBackwardsFrom(element,
>                                   Traversal.textNodeFinder);
>                  if (text != null) {
>                          markManager.set(Mark.DOT, text,
> text.getTextLength(), /*cursor*/ true);
>                  }
>
>                  markManager.endMark();
>         }
>
> This works but the window scrolls automatically to bring the DOT into view.
> Is there any way to avoid this behaviour? Not scrolling.
> I already positioned the view to display my component in the editor and
> I'm clicking on it so I don't want it to move. However I want to select
> the element. I'm also repositioning the DOT the the closest text node.
> If I don't do that ,it jumps to the previous text position which may be
> very far away and it's even worse.
>

[Not 100% sure of my answer, because I've not a full picture of what you 
do.]

Please try this:

First select the element *then* position it in the view. (I mean, not 
the opposite order: first position, then select.)
 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to