It seems that scripts in Dialogs can not postMessage to main thread like scripts in Panel.
Dialogs an also post msg.
I use this function in my tagging plugin.