Merge pull request #17933 from Snuffleupagus/pr-17464-followup

Fix resetting of cursor-tools when closing the document (PR 17464 follow-up)
This commit is contained in:
Tim van der Meij 2024-04-12 13:32:52 +02:00 committed by GitHub
commit e005e6ecdd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View File

@ -106,7 +106,14 @@ class PDFCursorTools {
#addEventListeners() { #addEventListeners() {
this.eventBus._on("switchcursortool", evt => { this.eventBus._on("switchcursortool", evt => {
this.switchTool(evt.tool); if (!evt.reset) {
this.switchTool(evt.tool);
} else if (this.#prevActive !== null) {
annotationEditorMode = AnnotationEditorType.NONE;
presentationModeState = PresentationModeState.NORMAL;
enableActive();
}
}); });
let annotationEditorMode = AnnotationEditorType.NONE, let annotationEditorMode = AnnotationEditorType.NONE,
@ -131,15 +138,6 @@ class PDFCursorTools {
} }
}; };
this.eventBus._on("secondarytoolbarreset", evt => {
if (this.#prevActive !== null) {
annotationEditorMode = AnnotationEditorType.NONE;
presentationModeState = PresentationModeState.NORMAL;
enableActive();
}
});
this.eventBus._on("annotationeditormodechanged", ({ mode }) => { this.eventBus._on("annotationeditormodechanged", ({ mode }) => {
annotationEditorMode = mode; annotationEditorMode = mode;

View File

@ -182,6 +182,7 @@ class SecondaryToolbar {
this.#updateUIState(); this.#updateUIState();
// Reset the Scroll/Spread buttons too, since they're document specific. // Reset the Scroll/Spread buttons too, since they're document specific.
this.eventBus.dispatch("switchcursortool", { source: this, reset: true });
this.#scrollModeChanged({ mode: ScrollMode.VERTICAL }); this.#scrollModeChanged({ mode: ScrollMode.VERTICAL });
this.#spreadModeChanged({ mode: SpreadMode.NONE }); this.#spreadModeChanged({ mode: SpreadMode.NONE });
} }