feat: add keyboard-based mouse action helper with Zustand integration
- Implemented `mouseActionHelper.ts` to track modifier keys (e.g. CONTROL, SHIFT) - Dynamically constructs mouse+modifier combos (e.g. left+CONTROL) - Updates Zustand store (`useMouseNoteStore`) with appropriate notes - Supports multi-key combinations and cleans up listeners on unmount
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import { useMouseNoteStore } from "../../store/useUIToggleStore";
|
||||
|
||||
const actionNotes: Record<string, string> = {
|
||||
'left+CONTROL': 'Box Select',
|
||||
'left+SHIFT': 'Multi Select',
|
||||
'middle+CONTROL': 'Zoom In',
|
||||
};
|
||||
|
||||
export function mouseActionHelper(
|
||||
onUpdate: (notes: {
|
||||
Leftnote: string;
|
||||
Middlenote: string;
|
||||
Rightnote: string;
|
||||
}) => void
|
||||
) {
|
||||
|
||||
export function mouseActionHelper() {
|
||||
const setNotes = useMouseNoteStore.getState().setNotes;
|
||||
|
||||
const activeKeys = new Set<string>();
|
||||
|
||||
function updateNotesFromKeys() {
|
||||
@@ -19,7 +18,7 @@ export function mouseActionHelper(
|
||||
const middleKey = ['middle', ...sortedKeys].join('+');
|
||||
const rightKey = ['right', ...sortedKeys].join('+');
|
||||
|
||||
onUpdate({
|
||||
setNotes({
|
||||
Leftnote: actionNotes[leftKey] || '',
|
||||
Middlenote: actionNotes[middleKey] || '',
|
||||
Rightnote: actionNotes[rightKey] || '',
|
||||
|
||||
Reference in New Issue
Block a user