mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Implement centralized event management system with priority handling and state tracking
- Enhanced EventManager class to support priority-based event handling, conditional execution, and automatic cleanup. - Integrated event management into BulkManager for global keyboard shortcuts and marquee selection events. - Migrated mouse tracking and node selector events to UIHelpers for better coordination. - Established global event handlers for context menu interactions and modal state management. - Added comprehensive documentation for event management implementation and usage. - Implemented initialization logic for event management, including error handling and cleanup on page unload.
This commit is contained in:
@@ -8,7 +8,6 @@ import { LoraContextMenu } from './LoraContextMenu.js';
|
||||
import { RecipeContextMenu } from './RecipeContextMenu.js';
|
||||
import { CheckpointContextMenu } from './CheckpointContextMenu.js';
|
||||
import { EmbeddingContextMenu } from './EmbeddingContextMenu.js';
|
||||
import { state } from '../../state/index.js';
|
||||
|
||||
// Factory method to create page-specific context menu instances
|
||||
export function createPageContextMenu(pageType) {
|
||||
@@ -24,34 +23,4 @@ export function createPageContextMenu(pageType) {
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize context menu coordination for pages that support it
|
||||
export function initializeContextMenuCoordination(pageContextMenu, bulkContextMenu) {
|
||||
// Centralized context menu event handler
|
||||
document.addEventListener('contextmenu', (e) => {
|
||||
const card = e.target.closest('.model-card');
|
||||
if (!card) {
|
||||
// Hide all menus if not right-clicking on a card
|
||||
pageContextMenu?.hideMenu();
|
||||
bulkContextMenu?.hideMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// Hide all menus first
|
||||
pageContextMenu?.hideMenu();
|
||||
bulkContextMenu?.hideMenu();
|
||||
|
||||
// Determine which menu to show based on bulk mode and selection state
|
||||
if (state.bulkMode && card.classList.contains('selected')) {
|
||||
// Show bulk menu for selected cards in bulk mode
|
||||
bulkContextMenu?.showMenu(e.clientX, e.clientY, card);
|
||||
} else if (!state.bulkMode) {
|
||||
// Show regular menu when not in bulk mode
|
||||
pageContextMenu?.showMenu(e.clientX, e.clientY, card);
|
||||
}
|
||||
// Don't show any menu for unselected cards in bulk mode
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user