messenger.windows API Enhancements- add onBeforeRemoved Event, etc
Categories
(Thunderbird :: Untriaged, enhancement)
Tracking
(Not tracked)
People
(Reporter: WoofGrrrr, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Steps to reproduce:
I looked at the messenger.windows API for an onBeforeRemoved Event. Plus onMoved and onResized.
Actual results:
They're not there
Expected results:
I would like to save the last-known position and size for later use when the Window is opened again. I can't figure out any way to do this with the existing API.
I believe the onRemoved event is too late, as, even if you have the Window ID, and you can get a Window, it's useless because it seems the Window has already been destroyed. The top, left, width, and height properties are all undefined. And I see "Uncaught (in promise) Error: Invalid window ID: xxx undefined" even though messenger.windows.get("xxx") returned a Window (confusing.)
I'm also looking for a way to prevent a Window from actually closing, or to automatically save, for example, when the window has unsaved changes. I know it's easy enough to auto-save for most user changes, like button clicks, but I'm thinking more about text input. I know it's possible to listen for text change events, but I don't want to save for each and every text change.... and what if the user cancels their change(s) (ctrl-z, etc.)?
It would really help if the messenger.windows API had an onBeforeRemoved event. And if your code could return something from the onBeforeRemoved listener to prevent the Window from closing, that would help as well.
Even onMoved and onResized events would help with saving the last known Window position and size. But not with unsaved data.
Description
•