feat(npc-dialogue): select nodes on click, edit on double-click
- Single click now only selects a node; the edit dialog opens on double-click so the Del-to-delete flow is never interrupted by a modal - Guard the canvas double-click handler so double-clicking a node can never also spawn a new dialogue node behind the dialog - Update the editor hint text to describe the new click model
This commit is contained in:
parent
089246def8
commit
1f7729c509
1 changed files with 9 additions and 4 deletions
|
|
@ -200,6 +200,9 @@ function FlowEditor() {
|
||||||
const onCanvasDoubleClick = useCallback(
|
const onCanvasDoubleClick = useCallback(
|
||||||
(e: ReactMouseEvent<HTMLDivElement>) => {
|
(e: ReactMouseEvent<HTMLDivElement>) => {
|
||||||
const target = e.target as HTMLElement;
|
const target = e.target as HTMLElement;
|
||||||
|
// Node double-clicks open the edit dialog (onNodeDoubleClick); they
|
||||||
|
// must never also spawn a new node.
|
||||||
|
if (target.closest?.(".react-flow__node")) return;
|
||||||
if (!target.closest?.(".react-flow__pane")) return;
|
if (!target.closest?.(".react-flow__pane")) return;
|
||||||
const pos = rf.screenToFlowPosition({ x: e.clientX, y: e.clientY });
|
const pos = rf.screenToFlowPosition({ x: e.clientX, y: e.clientY });
|
||||||
addNode("dialogue", pos);
|
addNode("dialogue", pos);
|
||||||
|
|
@ -452,7 +455,8 @@ function FlowEditor() {
|
||||||
applyConnection(sourceId, targetId, connectionState.fromHandle?.id);
|
applyConnection(sourceId, targetId, connectionState.fromHandle?.id);
|
||||||
}}
|
}}
|
||||||
isValidConnection={isValidConnection}
|
isValidConnection={isValidConnection}
|
||||||
onNodeClick={(_e, node) => setEditingNodeId(node.id)}
|
// Single click selects (React Flow default); double-click edits.
|
||||||
|
onNodeDoubleClick={(_e, node) => setEditingNodeId(node.id)}
|
||||||
onNodeContextMenu={onNodeContextMenu}
|
onNodeContextMenu={onNodeContextMenu}
|
||||||
onPaneClick={onPaneClick}
|
onPaneClick={onPaneClick}
|
||||||
onPaneContextMenu={onPaneContextMenu}
|
onPaneContextMenu={onPaneContextMenu}
|
||||||
|
|
@ -473,9 +477,10 @@ function FlowEditor() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-[10px] text-zinc-500">
|
<p className="text-[10px] text-zinc-500">
|
||||||
Click a node to edit. Select and press Del (or right-click) to delete. Double-click the
|
Click a node to select it, double-click to edit. Select and press Del (or right-click) to
|
||||||
canvas for a new dialogue node; right-click it for any type. Drag a row's dot to wire
|
delete. Double-click the canvas for a new dialogue node; right-click it for any type. Drag
|
||||||
that exact choice or branch. Use Expand to fill the screen (Esc to shrink).
|
a row's dot to wire that exact choice or branch. Use Expand to fill the screen (Esc to
|
||||||
|
shrink).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{contextMenu && (
|
{contextMenu && (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue