Is there an example of how to create a custom event on a custom perspective component?
I’ve been trying to follow another thread on how to do this:
http://forum.inductiveautomation.com/t/creating-a-component-event/30403/2
However, the JsonSchema class fails to parse the example in the following post, which causes my module to fail to load:
http://forum.inductiveautomation.com/t/creating-a-component-event/30403/9
I’m running on Ignition 8.0.10, fresh install.
I’ve moved the events
key out to a separate json file, which the JsonSchema.parse
fails to load:
{
"type": "object",
"events": [
{
"name": "onCustomClick",
"description": "This event is fired when a Component is clicked.",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the component."
}
}
}
}
]
}
This is the code setting up the component:
package org.example.common.component.display;
import java.util.List;
import com.inductiveautomation.ignition.common.jsonschema.JsonSchema;
import com.inductiveautomation.perspective.common.api.ComponentDescriptor;
import com.inductiveautomation.perspective.common.api.ComponentDescriptorImpl;
import com.inductiveautomation.perspective.common.api.ComponentEventDescriptor;
import org.example.common.RadComponents;
public class RadManager {
public static String COMPONENT_ID = "example.controller.manager";
public static JsonSchema SCHEMA = JsonSchema.parse(RadComponents.class.getResourceAsStream("/radmanager.props.json"));
public static JsonSchema EVENT_SCHEMA = JsonSchema.parse(RadComponents.class.getResourceAsStream("/radmanager.event.json")); // Line that causes the error
public static ComponentEventDescriptor EVENT_DESCRIPTOR = new ComponentEventDescriptor("onCustomClick", EVENT_SCHEMA);
public static ComponentDescriptor DESCRIPTOR = ComponentDescriptorImpl.ComponentBuilder.newBuilder()
.withPaletteCategory(RadComponents.COMPONENT_CATEGORY)
.withPaletteDescription("A component to holding custom events.")
.withId(COMPONENT_ID)
.withModuleId(RadComponents.MODULE_ID)
.withSchema(SCHEMA) // this could alternatively be created purely in Java if desired
.withPaletteName("Rad Manager")
.withDefaultMetaName("radManager")
.withEvents(List.of(EVENT_DESCRIPTOR))
.shouldAddToPalette(true)
.withResources(RadComponents.BROWSER_RESOURCES)
.build();
}
Any help would be appreciated.