# Create a event-object programmatic

**URL:** <https://forum.servoy.com/t/create-a-event-object-programmatic/14785>\
**Category:** Classic Servoy\
**Created:** [September 30, 2011, 12:44pm UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785 "2011-09-30T12:44:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GabrielWyss](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@GabrielWyss](https://forum.servoy.com/u/GabrielWyss)\
**Post date:** [September 30, 2011, 12:44pm UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/1 "2011-09-30T12:44:27Z")

</div>

Is it possible to create a event-object programmatic?  
I want to call a function who expect a event as parameter from my code.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [September 30, 2011, 8:58pm UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/2 "2011-09-30T20:58:37Z")

</div>

Hi Gabriel,

As far as I know you can’t create your own JSEvent object.  
I suggest you file a feature request.

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 30, 2011, 9:20pm UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/3 "2011-09-30T21:20:43Z")

</div>

Depending on what you want to do, you could simulate it, creating a JavaScript Object with similar properties and methods.  
Of course it would not return true to a test of instanceof JSEvent, but it might do the trick if all you want to do is to pass a few information to a target method.  
Not sure I would recommend that though, but it all depends on what you are doing.

---

<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:** [October 3, 2011, 9:35am UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/4 "2011-10-03T09:35:20Z")

</div>

my first question is: what is the usecase?  
Why do you want to call an event method by your own (business?) code?

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)\
**Post date:** [October 3, 2011, 8:14pm UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/5 "2011-10-03T20:14:44Z")

</div>

I was looking for this the other day as well and it was while attempting to try and conform to the correct inputs of an existing event method that I wanted to call programatically. No functional reason I can think of in my case – more of a best practices interest.

---

<div class="post-metadata">

**Author:** ![GabrielWyss](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@GabrielWyss](https://forum.servoy.com/u/GabrielWyss)\
**Post date:** [October 7, 2011, 6:53am UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/6 "2011-10-07T06:53:15Z")

</div>

I like to call a method of the Servoy Framework that expect a event as parameter.  
The method evaluate the getElementName() and getFormName() from the event.  
Normally, the method will be called from a button on a form, but I like to call this method from a formmethod and on this point I dont have a event.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [October 7, 2011, 7:15am UTC](https://forum.servoy.com/t/create-a-event-object-programmatic/14785/7 "2011-10-07T07:15:54Z")

</div>

Hi Gabriel,

Is this form method of yours triggered by another button/event?  
If this is also the form/element that you want the framework method to use you can simply pass the JSEvent object from your original button/event to the framework method.

Hope this helps.
