I am developing a simple plugin for eclipse where I want to detect what the user (who is opening a project file and typing in an editor) is typing. So far I have got the current workbench, currently active editor and the property changes made to the editor using the IPropertyListener; but I am repeatedly failing to detect whether any key is pressed or not.
the code:
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
System.out.println
("Yeah the editor is visible..." + page.isEditorAreaVisible() + "with ..." + page.toString() );
IEditorPart theEditor = page.getActiveEditor() ;
IPropertyListener myPropL = new IPropertyListener()
{
@Override
public void propertyChanged(Object arg0, int arg1)
{
// TODO Auto-generated method stub
System.out.println("This is : " + arg0.toString() );
}
};
theEditor.addPropertyListener(myPropL);
I fixed it by myself.
This is the solution :
get the IDocumentListener using
IDocumentListener lr = new IDocumentListener()Override the
documentChanged(DocumentEvent arg0)and use the arg0 parameter to get the typed text and the typed key using arg0.offset.For further questions happy to help 🙂