fix: scale menu on grid canvas, not keybed; erase sweep removed
- Context menu (Scales) appears at right-click position on grid canvas - Removed erase sweep on right-click (blocked brush after menu close) - Removed keybed onContextMenu (was wrong position) - Store menu origin ref so sub-menus don't drift on hover
This commit is contained in:
+8
-12
@@ -4912,7 +4912,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
|
|
||||||
if (scaleMenuPos) setScaleMenuPos(null);
|
if (scaleMenuPos) setScaleMenuPos(null);
|
||||||
|
|
||||||
// Right click -> Quick delete note or start erase sweep
|
// Right click -> Quick delete note
|
||||||
if (e.button === 2) {
|
if (e.button === 2) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const clickedNote = notes.find(n => {
|
const clickedNote = notes.find(n => {
|
||||||
@@ -4923,11 +4923,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
setNotes(prev => prev.filter(n => n.id !== clickedNote.id));
|
setNotes(prev => prev.filter(n => n.id !== clickedNote.id));
|
||||||
setSelectedNoteIds(prev => prev.filter(id => id !== clickedNote.id));
|
setSelectedNoteIds(prev => prev.filter(id => id !== clickedNote.id));
|
||||||
showToast('Đã xóa nốt!', 'info');
|
showToast('Đã xóa nốt!', 'info');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Start erase sweep (right-click on empty space only)
|
|
||||||
notesBeforeDragRef.current = JSON.parse(JSON.stringify(notes));
|
|
||||||
setDraggedNote({ mode: 'erase_sweep', visitedPitches: [pitch] });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5243,6 +5239,9 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
|
|
||||||
const handleContextMenu = (e) => {
|
const handleContextMenu = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const pos = { x: e.clientX, y: e.clientY, parentKey: null };
|
||||||
|
scaleMenuOriginRef.current = { x: pos.x, y: pos.y };
|
||||||
|
setScaleMenuPos(pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ccDragRef = React.useRef(null);
|
const ccDragRef = React.useRef(null);
|
||||||
@@ -5364,12 +5363,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
} catch (err) { console.error('playNote error:', err); }
|
} catch (err) { console.error('playNote error:', err); }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseUp: () => { keybedMouseDownRef.current = false; },
|
onMouseUp: () => { keybedMouseDownRef.current = false; }
|
||||||
onContextMenu: (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
setScaleMenuPos({ x: e.clientX, y: e.clientY, parentKey: null });
|
|
||||||
}
|
|
||||||
}, showLabel && label)
|
}, showLabel && label)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -5449,6 +5443,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
};
|
};
|
||||||
const [selectedScale, setSelectedScale] = React.useState(null);
|
const [selectedScale, setSelectedScale] = React.useState(null);
|
||||||
const [scaleMenuPos, setScaleMenuPos] = React.useState(null);
|
const [scaleMenuPos, setScaleMenuPos] = React.useState(null);
|
||||||
|
const scaleMenuOriginRef = React.useRef(null);
|
||||||
const [aiPrompt, setAiPrompt] = React.useState('');
|
const [aiPrompt, setAiPrompt] = React.useState('');
|
||||||
const [aiLoading, setAiLoading] = React.useState(false);
|
const [aiLoading, setAiLoading] = React.useState(false);
|
||||||
const [showCC, setShowCC] = React.useState(true);
|
const [showCC, setShowCC] = React.useState(true);
|
||||||
@@ -5533,7 +5528,8 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
const parentKey = key;
|
const parentKey = key;
|
||||||
const isOpen = scaleMenuPos && scaleMenuPos.parentKey === parentKey;
|
const isOpen = scaleMenuPos && scaleMenuPos.parentKey === parentKey;
|
||||||
pushItem(key + " ▸", () => setSelectedScale(null), false, () => {
|
pushItem(key + " ▸", () => setSelectedScale(null), false, () => {
|
||||||
setScaleMenuPos({ x: scaleMenuPos.x + 120, y: scaleMenuPos.y, parentKey });
|
const origin = scaleMenuOriginRef.current || scaleMenuPos;
|
||||||
|
setScaleMenuPos({ x: origin.x + 140, y: origin.y, parentKey });
|
||||||
});
|
});
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
Object.keys(val).forEach(subKey => {
|
Object.keys(val).forEach(subKey => {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user