unsoluble / smalltime

A small FoundryVTT module for displaying and controlling the current time of day.
MIT License
24 stars 15 forks source link

Replace problematic `Escape` avoidance code with a small hack #105

Closed sPOiDar closed 2 years ago

sPOiDar commented 2 years ago

The correct fix here would be to render the application without using a popout at all, but that would require a larger refactor. This small hack simply removes the app from the ui.windows list on render, which avoids it being a candidate for close via Escape.

I started with the goal of removing the special handling I had to put into Stream View to avoid touching Small Time. Unfortunately this change won't let me do that, since it's still rendering a popout, but at least it will let you delete a bunch of ugly code that doesn't really belong in this module, and doesn't play well with others.

I'd love to fix this properly, but I don't have the time to dedicate to untangling the rest of the code here to decouple it from FormApplication and move it into a regular Application for non-popout rendering (which I think is what would be required).

unsoluble commented 2 years ago

Hmm, will have to take a look at the ramifications for this, as I do use ui.windows in a couple places to check if the app has already been rendered. Is an interesting approach though, thanks!

(And yeah, I've been aware of the need to refactor for popOut: false for ages, but likewise it's something I haven't felt like spending time on.)

sPOiDar commented 2 years ago

I do use ui.windows in a couple places to check if the app has already been rendered

Ah sorry, didn't notice. I've pushed an updated change that stores the opened state in a static member on the class.