feat: Enhance cursor handling and mouse action notes in the footer and builder components
This commit is contained in:
@@ -3,14 +3,19 @@ export const handleCanvasCursors = (name: string) => {
|
||||
if (!canvas) return;
|
||||
|
||||
const cursorMap: Record<string, string> = {
|
||||
default: '',
|
||||
'draw-wall': 'draw',
|
||||
'draw-aisle': 'draw',
|
||||
'draw-zone': 'draw',
|
||||
'draw-floor': 'draw',
|
||||
measure: 'measure',
|
||||
delete: 'pointer',
|
||||
pointer: 'pointer',
|
||||
grab: 'hand',
|
||||
grabbing: 'hand-closed',
|
||||
pen: 'pen',
|
||||
'free-hand': 'hand',
|
||||
move: 'move',
|
||||
// Add more mappings as needed
|
||||
};
|
||||
|
||||
46
app/src/utils/mouseUtils/mouseHelper.ts
Normal file
46
app/src/utils/mouseUtils/mouseHelper.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
) {
|
||||
const activeKeys = new Set<string>();
|
||||
|
||||
function updateNotesFromKeys() {
|
||||
const sortedKeys = Array.from(activeKeys).sort();
|
||||
const leftKey = ['left', ...sortedKeys].join('+');
|
||||
const middleKey = ['middle', ...sortedKeys].join('+');
|
||||
const rightKey = ['right', ...sortedKeys].join('+');
|
||||
|
||||
onUpdate({
|
||||
Leftnote: actionNotes[leftKey] || '',
|
||||
Middlenote: actionNotes[middleKey] || '',
|
||||
Rightnote: actionNotes[rightKey] || '',
|
||||
});
|
||||
}
|
||||
|
||||
function handleKeyDown(event: KeyboardEvent) {
|
||||
activeKeys.add(event.key.toUpperCase());
|
||||
updateNotesFromKeys();
|
||||
}
|
||||
|
||||
function handleKeyUp(event: KeyboardEvent) {
|
||||
activeKeys.delete(event.key.toUpperCase());
|
||||
updateNotesFromKeys();
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener('keyup', handleKeyUp);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
window.removeEventListener('keyup', handleKeyUp);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user