Skip to content

Commit da70d36

Browse files
author
AlexJitianu
committed
A sample plugin for registering a mouse listener in the text page.
1 parent 04b3691 commit da70d36

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE plugin PUBLIC "-//Oxygen Plugin" "../plugin.dtd">
2+
<plugin
3+
id="com.oxygenxml.text.mouse"
4+
name="Adds a mouse listener in the text page"
5+
description="Plugin that intercepts mouse events in the text page."
6+
version="1.0"
7+
vendor="Syncro Soft"
8+
class="ro.sync.exml.plugin.Plugin"
9+
classLoaderType="preferReferencedResources">
10+
<extension type="WorkspaceAccessJS" href="wsAccess.js"/>
11+
</plugin>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function applicationStarted(pluginWorkspaceAccess) {
2+
Packages.java.lang.System.err.println("Application started " + pluginWorkspaceAccess);
3+
4+
var editorListener = {
5+
editorOpened : function (editorLocation) {
6+
var editorAccess = pluginWorkspaceAccess.getEditorAccess(editorLocation, Packages.ro.sync.exml.workspace.api.PluginWorkspace.MAIN_EDITING_AREA);
7+
8+
if (editorAccess.getCurrentPageID() == "Text") {
9+
var textPage = editorAccess.getCurrentPage();
10+
var textComponent = textPage.getTextComponent();
11+
12+
var mouseListener = {
13+
mouseClicked: function(event) {
14+
Packages.java.lang.System.err.println("Mouse clicked");
15+
},
16+
mousePressed: function(event) {
17+
Packages.java.lang.System.err.println("Mouse pressed");
18+
},
19+
mouseReleased: function(event) {
20+
Packages.java.lang.System.err.println("Mouse released");
21+
}
22+
}
23+
24+
textComponent.addMouseListener(new JavaAdapter(Packages.java.awt.event.MouseListener, mouseListener));
25+
}
26+
}
27+
};
28+
29+
pluginWorkspaceAccess.addEditorChangeListener(new JavaAdapter(Packages.ro.sync.exml.workspace.api.listeners.WSEditorChangeListener, editorListener), Packages.ro.sync.exml.workspace.api.PluginWorkspace.MAIN_EDITING_AREA);
30+
31+
}
32+
33+
function applicationClosing(pluginWorkspaceAccess) {
34+
Packages.java.lang.System.err.println("Application closing " + pluginWorkspaceAccess);
35+
}

0 commit comments

Comments
 (0)