Working with JS and Morphs (Getting current text from onscreen)

Is it possible with Javascript to do something like this by grabbing the onscreen morphs?
[scratchblocks]
report (currently being said by [Sprite1 v] :: sensing) :: control cap
report (current text in ask box :: sensing) :: control cap
[/scratchblocks]

Why you don't store what the sprite ask in a global var at the same time the sprite ask it?

No, I mean what the user inputs into the textbox while it's onscreen.

For what purpose

i'm making a command system- it would be nice if i could show the parameters for a given command when it's detected that it's being typed

Perhaps take a look at the source code and see if you can find anything that can help you.

You can get the current speech of a sprite on SpriteMorph.children[0].contents
It only works with strings though

Better version:

return (this.talkBubble()?.contents)||"";

(You can replace "this" with whatever sprite...)

Even better version:
return (this.talkBubble()?.contents)||(this.talkBubble()?.children[0]);
Now works with everything, not just strings

My version at least worked with lists, but I didn't test on sprites..
Edit: Works on sprites too.

well, I found this block in your custom blocks project...

script

if(this instanceof StageMorph){
throw new TypeError("Cannot read property \
'apply' of undefined");}
var contents = this.talkBubble();
if (!contents) return '';
contents = contents.contentsMorph;
if (!(contents instanceof TextMorph))
return contents;
return contents.text;

Get the contents of the current sprite's speech bubble:

return (this.talkBubble()?.contents)||"";

Get the contents of the ask box:

return (world.children[0].stage.children.find(e=>
e instanceof StagePrompterMorph)?.inputField
.contents().text.text)||"";

(Both will report nothing if there's no active ask box/speech bubble.)

WOAHH THIS GOT CRAZY FAST
Thank you guys so much!
I do have one more idea and idk if anybody can pull this off but here goes:
Is it possible to do the reverse; put text INTO the ask box?

world.children[0].stage.children.find(e=> e instanceof StagePrompterMorph)?.inputField .contents().text.text = 'hello world'
I don't know if it will work though

cool, i'll test it in a sec but first uhh
what happened here image

It's a text morph. use my version of the block

oof, ok
anyways let me test the text insert into ask block thing

Oop doesnt work

see the console and give me the error

Well i mean this is what it says onscreen image