AuthorCaretListener while clicking on an image

<oXygen/> general issues.
SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

AuthorCaretListener while clicking on an image

Post by SSC » Mon Mar 19, 2012 5:31 pm

Hello,

in the Eclipse Version of Oxygen I am using the ro.sync.ecss.extensions.api.AuthorCaretListener. When I click on an AuthorNode in the XML Editor the caretMoved method is invoked only once, like it should.
But when I click on an image in the WYSIWYG mode the caretMoved method is invoked 3 times.
The first AuhtorCaretEvent contains the AuthorNode of the onclicked image.
The second AuhtorCaretEvent contains the Parent of the AuthorNode of the onclicked image.
The third then again contains the AuhorNode of the onclicked image.

At first sight I thought it was a kind of event bubbling like it is done in JavaScript, but then it would not pass the leaf(onclicked image) again.

Is this a bug or a feature?
I just want the event only to be invoked once.

Do you have any suggestions how I can achieve this?

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

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

Re: AuthorCaretListener while clicking on an image

Post by Radu » Mon Mar 19, 2012 5:55 pm

Hi Simon,

As a default behavior when you click on an image element in the Author page Oxygen selects the entire element.
The first event gets fired when the caret is placed inside the element.
Then Oxygen automatically selects the <image> element, which means that first it moves the caret before the <image> (and this is the second event) and then it moves the caret after the image (which is the third received event).

What exactly do you want to achieve?
Do you also have a mouse listener installed and are you trying to somehow coordinate the two listeners to know when an image has been clicked?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: AuthorCaretListener while clicking on an image

Post by SSC » Mon Mar 19, 2012 6:22 pm

Hi Radu,

as I mentioned in former posts, we use our own properties view, which is able to show the meta data of objects which are selected in the Eclipse Workbench.
In order to manage the selection of tag elements in the Oxygen XML Editor I am using an AuthorCaretListener. Therefore the UI of the view changes according to the selection.
But when an image is selected the caretMoved event occurs three times, so that so view builds the controls for the meta data of the image tag element, then builds the UI for the parent and then again for the image.
The consequence is that the view creates and disposes the the suitable controls 2 times too often, which results in a flickering UI.

So this always occurs when a range is selected in the XML Editor.
I just realized that clicking on a tag element, when tags are activated, this also handled like you said about the clicking on images.

Does it really make sence to fire the caretMoved Event 3 times when an image or a tag element is onclicked?
Is there maybe a different listener, which can offer me the onclicked AuthorNode?

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

SSC
Posts: 206
Joined: Thu Dec 01, 2011 4:22 pm
Location: Hamburg, Germany

Re: AuthorCaretListener while clicking on an image

Post by SSC » Tue Mar 20, 2012 11:10 am

Hi,

I would guess that you also use the AuthorCaretListener for your Attributes View.
But the Attributes View does not load 3 times, when I click on an image or a tag element.
How do you handle it there?

Thanks in advance.

Best regards,

Simon
Simon Scholz
vogella GmbH
http://www.vogella.com

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

Re: AuthorCaretListener while clicking on an image

Post by Radu » Tue Mar 20, 2012 11:26 am

Hi Simon,

You are right :)

All our side views are coalescing caret move events. This means that they do not update on every caret move (the caret can be moved a lot when the user scrolls using the arrow keys for example).
Each of our views has a timer which gets triggered by each caret move.
So when the caret is moved a task is posted on the timer with a delay of 500 miliseconds. When the caret is moved again, the current task on the timer gets canceled (and thus the view will not react to it) and another task is posted and so on.
When the user has stopped moving the caret for half a second then the view is refreshed by that delayed task.

If you want you can contact us using our support@oxygenxml.com email address and I'll try to prepare some sample java code for this.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply