phetsims / paper-land

Build and explore multimodal web interactives with pieces of paper!
https://phetsims.github.io/paper-land/
MIT License
20 stars 3 forks source link

Creator: Speech has a default autoplay field #170

Open brettfiedler opened 1 year ago

brettfiedler commented 1 year ago

We should add a simple case for speech that is similar to the abstracted Sound view component.

brettfiedler commented 1 year ago

We'll want to be able to still add dependencies we can read out current model property values simply.

jessegreenberg commented 2 months ago

@brettfiedler can you please comment on the goal for this issue? I was curious about it because it seems like we already have a simple way to accomplish this with the current form.

The behavior described above can be done now by writing

return "Hello, world!"

in the control function.

I can see why abstracting a bit more was useful for sound because every sound uses a play() call, and it is nice to skip that if you want the sound to always play. But speech requires some unique text content so why not provide that in the control function instead of adding a new text input?

For the second comment:

We'll want to be able to still add dependencies we can read out current model property values simply.

If not using the control function, how would this be done? Would this require a new form or maybe we let the user fill in a string pattern with component names?

brettfiedler commented 2 months ago

In hindsight, I'm not sure about this one. I think for UI purposes, having the text field above the Control Function would be limited to playing basic speech. It'd be a super simple abstraction, but I think an expected one. It does indeed replace only "return some string" but for anyone not comfortable at all with code, it might be intuitive to just have it say something.

Probably any text in the control function should override the text entry (and empty it out once we save?).

brettfiedler commented 2 months ago

Turns out we need to move the Control Components section from the View Control Function menu into the View form itself. Then this should be possible. Making new issue.

brettfiedler commented 2 months ago

Assigning this for when #268 is complete.

brettfiedler commented 2 months ago

We do want a text field to enter and tie the entry to a controlled component.

Adding text to the control function overrides the text entry field.

If simple, we should clear the text entry field when the component is saved with code in the control function editor.

(for extra validation, maybe we should guarantee it has a return or speak() somewhere in the editor?)

jessegreenberg commented 2 months ago

OK, the above commits add a basic form entry for "basic" text, data and save and load functionality for the component, and the code generation.

If simple, we should clear the text entry field when the component is saved with code in the control function editor.

I thought this was a little tricky so I went with validation to start. You cannot create/save a Speech component if it has both a control function and a basic string.

maybe we should guarantee it has a return or speak() somewhere in the editor

Sounds good, I added this. Note that it isn't smart enough to skip comments and will let you create/save with // speak() in the control function.

@brettfiedler would you like to verify anything before we close? Do you have any recommendations for improving the labels/layout?

Capture