# Question about implementation of showLongText

**URL:** <https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740>\
**Category:** Help\
**Created:** [April 18, 2020, 4:35pm UTC](https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740 "2020-04-18T16:35:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [April 18, 2020, 4:35pm UTC](https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740/1 "2020-04-18T16:35:41Z")

</div>

I have a question about part of the implementation of [`showLongText`](https://github.com/microsoft/pxt-common-packages/blob/e4b148bb471e8553f0ca27dade72ca1c2869c97e/libs/game/textDialogs.ts#L450-L554):

I think I mostly understand the relationship between [the `game.onUpdate` handler](https://github.com/microsoft/pxt-common-packages/blob/e4b148bb471e8553f0ca27dade72ca1c2869c97e/libs/game/textDialogs.ts#L522) and the [pauseUntil](https://github.com/microsoft/pxt-common-packages/blob/e4b148bb471e8553f0ca27dade72ca1c2869c97e/libs/game/textDialogs.ts#L552) callback… but I can’t find where the `onUpdate` handler is actually removed. I’ve confirmed that code doesn’t continue to run after the dialog is closed, but I can’t seem to find whether it’s the [scene pop](https://github.com/microsoft/pxt-common-packages/blob/e4b148bb471e8553f0ca27dade72ca1c2869c97e/libs/game/textDialogs.ts#L532) or the completion of the `pauseUntil` or… ? that ends up ultimately removing the `onUpdate` that’s drawing the dialog.

Thanks!

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [April 18, 2020, 5:34pm UTC](https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740/2 "2020-04-18T17:34:41Z")

</div>

It’s the `scene.pop`; the `on game update` events are registered on the scene’s event context, and will cease to run when you push or pop a scene and another event context ‘takes over’.

For what it’s worth, it does look like the pause until there is unneeded; the update event is guaranteed to run synchronously with the rest of the game update loop, so we can probably just swap `controller._setUserEventsEnabled(true);` to where `done = true;` is set and drop the `done` boolean and the async pause. Haven’t tested that though

---

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [April 18, 2020, 5:52pm UTC](https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740/3 "2020-04-18T17:52:25Z")

</div>

Awesome. Thanks so much.

I _was_ also curious about `controller._setUserEventsEnabled(false)` / `controller._setUserEventsEnabled(true)` calls. From its name, that doesn’t look like a “public” api. My intuition was that it suspended processing of user input for things like the sprite controller block. But it seems like pushing a scene is enough to prevent input getting through to a sprite below. Do you mind explaining a little more about the `_setUserEventEnabled`?

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [April 18, 2020, 6:05pm UTC](https://forum.makecode.com/t/question-about-implementation-of-showlongtext/1740/4 "2020-04-18T18:05:21Z")

</div>

Actually, I think you are right on that, it’s likely fully redundant. I think it might have been added at a time where we had some bugs around controller events not being properly attached to the scene, but it doesn’t seem necessary anymore. (and yes, you’re right on what that function does, it flips on a flag which determines which events are triggered: [https://github.com/microsoft/pxt-common-packages/blob/master/libs/game/controller.ts#L87](https://github.com/microsoft/pxt-common-packages/blob/master/libs/game/controller.ts#L87))

\_ at the front of a method / function name is generally our ‘not private, but don’t make it trivially exposed’ indicator; we probably have a little bit less of a bar on changing them as they’re thought of closer to implementation details, but the main reason we mark them that way is so they don’t show up in autocomplete (as we filter them out).
