Opening the WebSDK/CustomButton Example, That runs as expected.
Creating a new empty WebProject, Copying the “ExampleCustomButton” Class to the new Project. Adding the class to the Webpage, Adding Stoppoint to the ExecuteEvent-Event. Running, Clicking, Nothing happens.
Adding the Pressed-Event of the Button to the Control, adding some code inside. Rerun, Clicking, the Stoppoint insinde ExecuteEvent-Event is triggered.
IIRC the event must exist in the subclass for it to trigger
or
in the javascript code, you must add a “true” parameter to the triggerserverevent function call.
triggerServerEvent(eventName: string, parameters: JSONItem | null = null, forced: boolean = false)
Sends an event to the server for processing. eventName should match the Xojo event name. parameters are of type JSONItem. The forced parameter should be used sparingly, it is meant for sending events that otherwise send important information to your control even if the event hasn’t been explicitly implemented. For example, changes to the text in a textfield are always sent because the user has a reasonable expectation that the Value property of the field will be up to date, regardless of whether he or she implemented the ValueChanged event.
Yes, but the ExecuteEvet-Handler of the button class dindn’t even fire. There the subclasses event is raised.
Within the developper tools, I can see, that the “click” / triggerserverevent is not even sent from client to the server.
It is not nessecary to do an raiseevent on the serverside. Perhaps I want do other things (perhaps logging) when triggerserverevent is called on the client.
So before you do this, let’s talk about why this is designed this way…
The whole point of this design was to make it so that any events that have not been implemented will not generate traffic from the client to the server. So yes, if you’re sure that the event should always be reflected on the server, then you should do as @Jean-Yves_Pochez said and set forced to true. Otherwise, if it relies on user interaction to be meaningful, leave it as false and rethink your solution.
Until now - for me - it is now 100% clear HOW this is designed.
There is a boolean-return in the ExecuteEvent. What does that do? What does Xojo do if it return false?
An EventDefinition with the name “name” is not automatically triggered in this case.
If I trigger an Event with a different name then “name” is that enough?
Perhaps this all makes sense or not. But all the information in the documentation about that seems to be written from someone who doesn’t know about that.
if you return true it means that you handled the event and nothing more will be done by xojo
(like calling the event with the same name…)
ExecuteEvent(name as String, parameters as JSONItem) As Boolean
This event fires when an event is sent from the browser to the app using the triggerServerEvent JavaScript method. Return True if your control has handled the event.