Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Attach a ModifyListener when the XTextEditor gets focus.
Attach a ModifyListener when the XTextEditor gets focus. [message #1575073] Tue, 20 January 2015 16:06 Go to next message
Andy Ed is currently offline Andy EdFriend
Messages: 64
Registered: December 2009
Member
Hi,

I wish to attach a ModifyListener to the XTextEditor, the first time it gains focus (or some time prior to editing, such as on opening?). Is there any part of the XText API that could/should be used to achieve this?

Andy
Re: Attach a ModifyListener when the XTextEditor gets focus. [message #1575080 is a reply to message #1575073] Tue, 20 January 2015 16:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you have a look at org.eclipse.xtext.ui.editor.IXtextEditorCallback

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Attach a ModifyListener when the XTextEditor gets focus. [message #1575094 is a reply to message #1575080] Tue, 20 January 2015 16:21 Go to previous messageGo to next message
Andy Ed is currently offline Andy EdFriend
Messages: 64
Registered: December 2009
Member
I will do so, thanks,
Re: Attach a ModifyListener when the XTextEditor gets focus. [message #1576473 is a reply to message #1575094] Wed, 21 January 2015 10:31 Go to previous messageGo to next message
Andy Ed is currently offline Andy EdFriend
Messages: 64
Registered: December 2009
Member
Hi,
I've been able to achieve the desired effect by extending NatureAddingEditorCallback, but imagine there's probably a better way to do this. There were runtime errors when I tried to attach a second IXtextEditorCallback, saying the there could only be one callback. How would I add another?


public class CustomXtextEditorCallback extends
NatureAddingEditorCallback {

@Override
public void afterCreatePartControl(XtextEditor editor) {
super.afterCreatePartControl(editor);
setup(editor);
}

private void setup(XtextEditor editor) {
StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();

ModifyListener eventBListener = RodinKeyboardPlugin.getDefault()
.createRodinModifyListener();
textWidget.addModifyListener(eventBListener);
}

}
Re: Attach a ModifyListener when the XTextEditor gets focus. [message #1576589 is a reply to message #1576473] Wed, 21 January 2015 12:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot reproduce that

	public void configureXtextEditorCallbacks(Binder binder) {
		binder.bind(IXtextEditorCallback.class).annotatedWith(Names.named("dontcare1")).to(XtextEditorCallback1.class);
		binder.bind(IXtextEditorCallback.class).annotatedWith(Names.named("dontcare2")).to(XtextEditorCallback2.class);
	}


works fine for me


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Attach a ModifyListener when the XTextEditor gets focus. [message #1580108 is a reply to message #1576589] Fri, 23 January 2015 09:37 Go to previous message
Andy Ed is currently offline Andy EdFriend
Messages: 64
Registered: December 2009
Member
That worked for me too: It's just difficult to find out how to do these things when you're not familiar with the technology. Thanks for your assistance.
Previous Topic:infinite loop in DocumentTokenSource
Next Topic:How to add brackets to the code generator
Goto Forum:
  


Current Time: Thu Apr 25 16:04:55 GMT 2024

Powered by FUDForum. Page generated in 0.03484 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top