cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I code "Execute during preview" capability in custom snap? (i.e. testing validation mode vs. run-time mode)

del
Contributor III

I have a snap, that I have developed, for which I would like to add the โ€œExecute during previewโ€ capability.
image
Can anyone provide me with java code capable of accomplishing this? I do not need the code to create the UI feature, property or variable. I just need the code to determine whether the execution process is in the validation or run-time mode.

TIA,
โ€“ Del

1 ACCEPTED SOLUTION

@del adding @Category(snap = SnapCategory.WRITE) to the class definition will automatically expose the โ€œExecute during previewโ€ checkbox. As @rohithmadhavan stated, behavior can be customized with SuggestExecutionProvider.

See Snap Development Documentation and Snap Development Documentation

View solution in original post

7 REPLIES 7

Hi JiWon,

Iโ€™m not sure exactly what youโ€™re asking. If you want to know how to define a checkbox property in a custom snap, youโ€™d have code something like this in your defineProperties method:

    propertyBuilder.describe("name", "label", "description")
            .type(SnapType.BOOLEAN)
            .defaultValue(true)
            .add();

JiWon
New Contributor II

Thanks ptaylor ๐Ÿ™‚

del
Contributor III

Hi @JiWon,

The solution for me was Robinโ€™s response above. Iโ€™ve highlighted the necessary code here (in context):

image