* Pointer middle button click processing. Part of processMouseDown. * @param e The pointerdown event * @param node The node to process a click event for
(e: CanvasPointerEvent, node: LGraphNode | undefined)
| 2657 | * @param node The node to process a click event for |
| 2658 | */ |
| 2659 | #processMiddleButton(e: CanvasPointerEvent, node: LGraphNode | undefined) { |
| 2660 | const { pointer } = this |
| 2661 | |
| 2662 | if ( |
| 2663 | LiteGraph.middle_click_slot_add_default_node && |
| 2664 | node && |
| 2665 | this.allow_interaction && |
| 2666 | !this.read_only && |
| 2667 | !this.connecting_links && |
| 2668 | !node.flags.collapsed |
| 2669 | ) { |
| 2670 | // not dragging mouse to connect two slots |
| 2671 | let mClikSlot: INodeSlot | false = false |
| 2672 | let mClikSlot_index: number | false = false |
| 2673 | let mClikSlot_isOut: boolean = false |
| 2674 | const { inputs, outputs } = node |
| 2675 | |
| 2676 | // search for outputs |
| 2677 | if (outputs) { |
| 2678 | for (const [i, output] of outputs.entries()) { |
| 2679 | const link_pos = node.getOutputPos(i) |
| 2680 | if (isInRectangle(e.canvasX, e.canvasY, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) { |
| 2681 | mClikSlot = output |
| 2682 | mClikSlot_index = i |
| 2683 | mClikSlot_isOut = true |
| 2684 | break |
| 2685 | } |
| 2686 | } |
| 2687 | } |
| 2688 | |
| 2689 | // search for inputs |
| 2690 | if (inputs) { |
| 2691 | for (const [i, input] of inputs.entries()) { |
| 2692 | const link_pos = node.getInputPos(i) |
| 2693 | if (isInRectangle(e.canvasX, e.canvasY, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) { |
| 2694 | mClikSlot = input |
| 2695 | mClikSlot_index = i |
| 2696 | mClikSlot_isOut = false |
| 2697 | break |
| 2698 | } |
| 2699 | } |
| 2700 | } |
| 2701 | // Middle clicked a slot |
| 2702 | if (mClikSlot && mClikSlot_index !== false) { |
| 2703 | const alphaPosY = |
| 2704 | 0.5 - |
| 2705 | (mClikSlot_index + 1) / |
| 2706 | (mClikSlot_isOut ? outputs.length : inputs.length) |
| 2707 | const node_bounding = node.getBounding() |
| 2708 | // estimate a position: this is a bad semi-bad-working mess .. REFACTOR with |
| 2709 | // a correct autoplacement that knows about the others slots and nodes |
| 2710 | const posRef: Point = [ |
| 2711 | !mClikSlot_isOut |
| 2712 | ? node_bounding[0] |
| 2713 | : node_bounding[0] + node_bounding[2], |
| 2714 | e.canvasY - 80, |
| 2715 | ] |
| 2716 |
no test coverage detected