Bug 253075 - [misc] No object:text-changed:insert events fired for method completion (and others)
Summary: [misc] No object:text-changed:insert events fired for method completion (and ...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux-GTK
: P3 normal with 4 votes (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL: http://bugzilla.gnome.org/show_bug.cg...
Whiteboard:
Keywords: accessibility
Depends on:
Blocks:
 
Reported: 2008-11-01 15:39 EDT by Mario Lang CLA
Modified: 2009-03-14 09:22 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Lang CLA 2008-11-01 15:39:26 EDT
In the code editor, whenever Eclipse performs automatic insertion like
matching parenthesis or method completion, accessibility infrastructure only
sees object:text-caret-moved but no object:text-changed:insert
which leaves the idea of the on screen text inside an assistive technology like
a screen reader out of sync with reality.
I observe this on Linux with GTK + AT-SPI.
To reproduce, simply invoke Ctrl+SPACE in a situation where only one possible
completion is valid.  The newly inserted text appears on screen, but
eclipse does not fire any object:text-changed:insert events via
ATK.  Use accerciser for a quick inspection tool.
Comment 1 Dani Megert CLA 2008-11-02 06:52:08 EST
Felipe, is there a way for the editor/StyledText to fire such events?
Comment 2 Felipe Heidrich CLA 2008-11-03 11:42:05 EST
Dani, in this case (auto insert text after control-space), you are not calling StyledText#replaceTextRange or StyledText#insert, are you ?
I believe you are changing the model directly.

Car, I looked at the code and the API calls that notify the accessible object when the text changes are not called when the text changes happen in the model. For example:

st.replaceTextRange(offset, length, "new text"); //notifies accessible object 
st.getContent().replaceTextRange(offset, length, "new text"); // does not notify accessible object 

I think all platforms have the same problem.
Comment 3 Dani Megert CLA 2008-11-13 11:09:26 EST
We don't update the model but call org.eclipse.swt.custom.new TextChangeListener() {...}.textChanged(TextChangedEvent).
Comment 4 Felipe Heidrich CLA 2008-11-19 14:31:39 EST
(In reply to comment #3)
> We don't update the model but call org.eclipse.swt.custom.new
> TextChangeListener() {...}.textChanged(TextChangedEvent).

I don't understand, textChanged is a event sent by the model when after a text change. The class sending this event is not an implementor of StyledTextContent ?

For me: StyledTextContent  == text model
Comment 5 Carolyn MacLeod CLA 2008-11-19 16:35:09 EST
(In reply to comment #2)
The accessible object is notified of the change in sendModifyEvent(Event event)
Are changes to the model supposed to invoke modify listeners?
Comment 6 Felipe Heidrich CLA 2008-11-19 16:52:10 EST
(In reply to comment #5)
> (In reply to comment #2)
> The accessible object is notified of the change in sendModifyEvent(Event event)
> Are changes to the model supposed to invoke modify listeners?

no, it doesn't. 

I think the fix is to move the code in sendModifyEvent to handleTextChanged and handleTextSet. These two method run a bit before sendModifyEvent, I hope that doesn't cause problems.
Comment 7 Carolyn MacLeod CLA 2008-11-19 22:48:23 EST
Modify event can't be cancelled, so I think it's fine to run the accessible notification code a little before the event is sent, as long as it is after the new text is displayed. Go for it.  :)
Comment 8 Dani Megert CLA 2008-11-20 03:00:45 EST
>I don't understand, textChanged is a event sent by the model when after a text
>change. The class sending this event is not an implementor of StyledTextContent
>?
Yes it is but besides the StyleTextContent we have the document. So, the document (and StyledText) can be changed in two ways (:
1) via StyledText > StyledTextContent.repalceTextRange > document > StyledTextContent.fireTextChang*
2) via document > StyledTextContent.fireTextChang* > StyledText

>Go for it.  :)
Moving to SWT.
Comment 9 Felipe Heidrich CLA 2009-02-26 11:33:10 EST
I can change the code but I don't have the means to test it.
Mario, can you help with the testing ?
Comment 10 Felipe Heidrich CLA 2009-02-26 11:56:03 EST
import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class PR253075 {
public static void main(String[] args) {
	Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	final StyledText text = new StyledText(shell, SWT.V_SCROLL | SWT.H_SCROLL);
	text.setText("start text");
	text.addListener(SWT.KeyDown, new Listener() {
		public void handleEvent(Event event) {
			if (event.keyCode == SWT.F1) {
				text.replaceTextRange(0, 0, "text");
			} else if (event.keyCode == SWT.F2) {
				text.getContent().replaceTextRange(0, 0, "content");
			} else if (event.keyCode == SWT.F3) {
				text.setText("setText");
			} else if (event.keyCode == SWT.F4) {
				text.getContent().setText("content.setText");
			}
		}
	});
	text.addListener(SWT.Modify, new Listener() {
		public void handleEvent(Event event) {
			System.out.println("Modify: " + event.text);
		}
	});
	shell.setSize(300, 100);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();
}

=-=-=-=-=-=-=-
Note, when the user uses F2 or F4 the text changes but no modify event is sent.
The accessible object is only notified when the modify event is sent.



Comment 11 Felipe Heidrich CLA 2009-02-26 12:26:58 EST
Fixed in HEAD > 20090226

Please verify
Comment 12 jose vilmar estacio de souza CLA 2009-03-14 09:22:13 EDT
(In reply to comment #11)
> Fixed in HEAD > 20090226
> 
> Please verify
> 

Testing with orca and build I20090313-0100. 
Now I can type the following:
int abCd;
abCctrl+space 

Orca reads abCd
This is great!!