I am trying to add a button to WidgetContextMenu if the selected widget is a Sticker and it is not locked.
I can get the type of widget from the widget object, but it is not clear where i can garner if the widget has been locked or not. This leads to my button being accessible on locked objects, as shown:
Can you please offer any guidance on how to tell whether the widget is locked from within the plugin code?
Hope this is clear and thanks in advance.
Best answer by Boris BorodyanskyView original
Unfortunately there’s no way right now to understand whether widget is locked or not.
Will add it to our backlog
But i have not yet found out, how the onClick Callback retrieves any info on the widget that was clicked. The callback from the SDK does not deliver anything.
I am afraid, that we have to get the info about the items that contextmenu is supposed to work on, from the current selection. But we might have to catch it in the outer widgets context method and not give it as a parameter in the onClick method.
Any thoughts or ideas?
Yes i have successfully added the button using the following (apologies for the formatting, it seems to be broken):
Getting the information that contextmenu is supposed to work on from the current selection should not be an issue here, as the resulting action (doStuff() in the above code) acts on the current selection anyway.
I am sorry but i’m not sure I understand this part. In essence I suppose I am asking is it possible to distinguish if a widget is locked from the context of a web plugin?
Just remove the parameter widgets in the onClick method and then it should work:
Since the widgets will not be given as a parameter to the onClick callback, but stay in the context of the getWidgetMenuItems context, you can still access the widgets there, if you do not put them as a parameter in the callback function.
I appreciate the guidance
@Falk Kühnel, howewer I am afraid the issue persists.
My updated code is here if it’s of interest:
I just made a few changes, that should help you to continue.