listerner for java

Discuss and ask questions about CADEditorX and XML API.

Moderators: admin, support, SDS

Post Reply
Posts: 2
Joined: 09 Mar 2015, 12:32

listerner for java

Post by StefzX » 09 Mar 2015, 12:37

Hello I'm using CadEditorX in Java via OLE.
I know i can execute some commands from code by submitting xml strings.

My question is: is it possible to know (for example with a listerner) where I'm clicking with the mouse? (on the drawing)

Thanks in advice

Posts: 2834
Joined: 30 Mar 2005, 11:36

Re: listerner for java

Post by support » 13 Mar 2015, 20:53

Hello Stefano,

It is possible to handle the OnProcess event (which is common for all events - OnMouseDown, OnSelectEntity, etc.) in Java code with a created OleListener. Have a look at the code snippet below. The event.arguments[0] returns the output XML string which can contain some information depending on what event has been fired.

Code: Select all

       OleControlSite sgCADEditor = null;
	    	sgCADEditor = new OleControlSite(frame, SWT.NONE, "CADEditorLib.SgCADEditor");
	    	int OnProcess = 224; // or 0x000000e0 - the identifier for the OnProcess event obtained from the type library  
	    	sgCADEditor.addEventListener(OnProcess, new OleListener() {
	    		public void handleEvent(OleEvent event) {
	    			if (event.detail != OnProcess) return;
	    			Variant aXML = event.arguments[0];
	    			if (aXML == null) return;
	    			String outputXML = aXML.getString();
The OnMouseDown event returns X and Y coordinates of the location where you click with the mouse. This event is disabled by default, in order to be able to handle this event with a created listener, you should enable it (or "sign to the event" in terms of CADEditorX) by processing the following XML command:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<cadsofttools version="2">
  <signtoevent Event="OnMouseDown" Enabled="True"/>
Technical Support E-mail:
Chat support on Skype:

Posts: 2
Joined: 09 Mar 2015, 12:32

Re: listerner for java

Post by StefzX » 15 Mar 2015, 22:24


Thanks a lot, it worked!
Otherwise i had to change "event.detail" into "event.type" to get it to work, just in case anybody else will look forward this feature in the future

Kind regards,
Stefano Franchini

Post Reply