Note: This is part of a longer series.
Now we need to make the plugin useful again. To do that, we're going to add some parameters to createRectangle
so we can call it with the user's specified paddings.
Pay attention to these sections in main.js
:
- Line 14: We've added
hPadding
andvPadding
as parameters - Lines 20, 21, and 26: Note that we've replaced
padding
with the appropriate horizontal or vertical padding - Line 79: We can check the
response
from a dialog to determine if the user canceled (pressed ESC or clicked "cancel") or if they want to apply the changes. - Line 81: The current selection can be obtained from the
scenegraph
module. - Lines 87-88: Using regular DOM methods we can extract the values the user typed in the two input fields.
- Line 90: Now we can call
createRectangle
. BecauseshowDialog
is async, we've actually returned a promise to XD (line 97), which means XD has held the scenegraph open for just this moment.