# plugin and events

**URL:** https://forum.servoy.com/t/plugin-and-events/14284
**Category:** Classic Servoy
**Created:** [July 11, 2011, 12:58pm UTC](https://forum.servoy.com/t/plugin-and-events/14284 "2011-07-11T12:58:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Marco\_R](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Marco\_R](https://forum.servoy.com/u/Marco_R)
#### Post date: [July 11, 2011, 12:58pm UTC](https://forum.servoy.com/t/plugin-and-events/14284/1 "2011-07-11T12:58:28Z")

</div>

Hi all,

I have a pos printer that I drive with the jpos controller through a plugin.  
Is possible to add to this controller three listeners and I would to assign a personal servoy function for each of they.  
Each Listener implements “java.util.EventListener” and accept a specific event Object: ErrorEvent,outputCompleteEvent etc…  
All these event objects have as father the “JposEvent” interface that has as father “java.util.EventObject”.

In fact I have made a class that implements these event interfaces and I’ve implemented the required function, if I rest into my plugin and I don’t interact with Servoy all works fine.

In my mind I have these generic ideas:

I have already managed these events so:  
Can I pass a servoy-function controller through the plugin, declare a pointer (as class variable) into my Java plugin and use it to call the function (with .call method… or Am I talking abount two different thing?)?

OR  
I woud follow this way l:  
“new Packages.javax.swing.event.MouseInputListener({ mouseReleased:globals.myFunction});”  
The problem, in this case, is that I don’t use a standard, already included, package but I import it from my plugins (maybe I don’t know something important…).

OR  
does exist any other way?

Thanks

Marco

---

<div class="post-metadata">

### Author: ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)
#### Post date: [July 12, 2011, 2:58pm UTC](https://forum.servoy.com/t/plugin-and-events/14284/2 "2011-07-12T14:58:55Z")

</div>

use the javascript function call back  
But don’t hold on the the actual function itself. use the FunctionDefinition class from servoy and use that call() function.

---

<div class="post-metadata">

### Author: ![Marco\_R](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Marco\_R](https://forum.servoy.com/u/Marco_R)
#### Post date: [July 13, 2011, 10:44am UTC](https://forum.servoy.com/t/plugin-and-events/14284/3 "2011-07-13T10:44:03Z")

</div>

Ok Johan, by using the FunctionDefinition I’ve solved!

I’ve used the _execute_ method of this class.

Thanks

Marco
