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