Home › Forum › Omnis General Forum › Raising events by code
-
Raising events by code
Posted by Uwe Smidt on April 23, 2026 at 1:02 pmDear $all,
Normally, events are risen by user interaction on a form or control. But sometimes, you may want to execute the code of an event handler not by user interaction, but by code.
Is this possible in Omnis? For example, I have a remote form with a dropList control, and I want to raise the on evClick method by code. How do I do that?
Thanx!
Uwe
Uwe Smidt replied 1 hour, 4 minutes ago 2 Members · 4 Replies -
4 Replies
-
Hi Uwe,
I would not recommend this.
It’ll be easier if you put the code from the $event method of the field into another method and then call this method from the button and the other place.
For example, you could add a method to your button, i.e. $updateData which has the code that you want to perform. Because the new method is now at the same button you can call this method from the $event method of the button like this: Do $cfield.$updateData()
And similar you can call the $updateData method from anywhere else in the form like this: Do $cinst.$objs.myButton.$updateData()
.. pretending the buttons name is “myButton”.
Does that help?
Best,
Andreas
-
Hi Andreas,
I was thinking of your proposed method as a workaround if I was not able to raise an event by code.
But you are right, it is not the workaround, but the proper way of doing it!
But asking for a (lazy) friend 😉 : even if was NOT clean coding style, is the a way to raise an event by code?
Best regards
Uwe
-
Hi Uwe,
if it is not a remote form but a window you can use Queue commands to generate events. But I cannot recommend this as it will give trouble later on when the code becomes more complicated. Imagine you would need to debug this.
For a remote form the only and possible a recommendation would be using the $okkeyobject and $cancelkeyobject property of the form. Those will trigger the evClick of a button when the user hits the enter or escape key. That said you can also dynamically assign those properties to allow different behaviour when the user hits the enter key for example.
You might also be interested in $keyboardshortcut client-side method. Check out the Whatsnew in Omnis Studio 11.2 of the last years ODC conference.
BTW. Are we going to meet at the ODC this year?
Best regards,
Andreas
-
Hi Andreas,
Yeah, this really sounds complicated! I’ll recommend my ‘friend’ to go the way you previously described!
As for the ODC, I’d love to attend and see all of you again, but I’m afraid I’ll have to ride a motorbike from Lima to Cartagena😪…
But maybe we’ll meet again at the next EurOmnis!
Best regards
Uwe
-
-
Log in to reply.