CanvasPointer. It decides whether a
press becomes a click, a double-click or a drag, and runs the callbacks you
assign for that press. Widgets drawn on the canvas use it through
onPointerDown.
Default behavior
- Dragging several selected items no longer requires holding Shift. Clicking one item while several are selected still deselects the others.
- Clicking a connected link on an input no longer disconnects and reconnects it.
- A small amount of movement between pointer down and pointer up still counts as a click. Once the pointer travels past the click drift limit, the press becomes a drag. Time does not affect the decision.
- A double-click needs two presses within the double-click time, at most three
times the click drift apart. Only a press that assigns
onDoubleClickcan complete a double-click.
Comfy.Pointer.ClickDrift and Comfy.Pointer.DoubleClickTime).
Selecting multiple items
Ctrl+ drag: begin a multi-selectCtrl+Shift+ drag: add to the selectionCtrl+ drag, thenShift: add to the selectionCtrl+ drag, thenAlt: remove from the selection
Handle pointer input on a widget
AssignonPointerDown on a widget. It runs on pointer down and receives the
pointer, the node and the canvas. Assign the callbacks you need on the pointer;
the canvas runs the right ones when the press resolves:
onClickandonDoubleClicknever run in the same press asonDragStart,onDragEndoronDragCancel.onDragcan run in a press that ends as a click, because it also receives movement inside the click drift limit.onDragStartruns once per drag, when the pointer first moves past the click drift limit. If the pointer is released past the limit before any movement event is reported,onDragStartruns on release,onDragEndruns right after it, andonDragdoes not run.- When a press assigns both
onClickandonDoubleClick, releasing the first press of a double-click runsonClick. The second press runsonDoubleClickinstead ofonClick, so makeonClicksafe to run first. The first click can also land on a nearby item instead of your widget, soonDoubleClickcan run without youronClickhaving run. onDragEndreceives the pointer up event of a drag.onDragCancelruns instead when the drag is interrupted, for example when pointer capture is lost.finallyruns once when the press ends. Assigningpointer.finallyruns the callback it replaces immediately. IfonPointerDowndoes not returntrue, the canvas assigns its ownfinally, so yours runs during pointer down. Returntruewhen you rely onfinallyfor cleanup.pointer.eDown,pointer.eMoveandpointer.eUpgive every callback access to the whole sequence of events.- Return
trueto stop the canvas from handling the press itself. - Remove any legacy
widget.mousehandler when you addonPointerDown. IfonPointerDownreturnstrue, the canvas keeps tracking the widget after release and keeps callingwidget.mouseon every pointer move.
Control the canvas cursor
canvas.state.hoveringOver holds bit flags for the item types under the
pointer, such as a node, group, reroute or link. Set
canvas.state.shouldSetCursor to false to stop the canvas from setting the
cursor style, then set it yourself:
shouldSetCursor is
false. Set your cursor again after the resize ends.