Closed pixelzoom closed 1 year ago
Since OopsDialog is modal, I think a better approach would be to eagerly create a single (global) instance of OopsDialog, use it wherever an OopsDialog is needed, and set it's StringProperty to display the desired message.
That is unfortunately not possible. Attempting to instantiate a Dialog as a static global results in a failure of this assertion in Dialog.ts:
sim: getGlobal( 'phet.joist.sim' ),
...
assert && assert( options.sim, 'sim must be provided, as Dialog needs a Sim instance' );
So in the above commit, I'm using one static instance of OopsDialog per screen for the "numer too big" message. I still need to address the OopsDialog in SeparateTermsDragListener.
Done.
We now have 3 static instances of OopsDialog, under equalityExplorer.global.view.dialogs
. EqualityExplorerSceneNode is responsible for creating those instances at startup. There are no PhetioCapsules involved.
I've also added documentation about how to test these dialogs, see EqualityExplorerSceneNode.ts.
Closing.
Related to https://github.com/phetsims/equality-explorer/issues/192 and #195 ...
OopsDialog is currently instantiated from a couple of places in the sim: EqualityExplorerSceneNode and SeparateTermsDragListener. The latter is problematic, because SeparateTermsDragListener is itself dynamic, so I can't use a PhetioCapsule there.
Since OopsDialog is modal, I think a better approach would be to eagerly create a single (global) instance of OopsDialog, use it wherever an OopsDialog is needed, and set it's StringProperty to display the desired message.