Skip to content

Click Distance

A hand on a mouse or a finger on a screen wobbles. NodeClickDistance and PaneClickDistance set how far the pointer may travel between press and release and still count as a click, so OnNodeClick and OnPaneClick are not lost to a shaky hand; NodeDragThreshold sets how far it must travel before the node starts to move.

node clicks: 0 · pane clicks: 0 · node moves: 0 · last: -
Nudge me a little, then a lot
Node 2
bit Blow

Try it

  • Click a node: node clicks goes up and last names it. Click the empty background: pane clicks goes up.
  • Press a node, move a few pixels and let go: the node moves (node moves goes up) and it still counts as a click, because the pointer stayed within the node click distance (20 px to begin with).
  • Drag a node further than that: it moves, but no click is reported. Do the same on the background: past the pane click distance the press was a pan, not a click.
  • Drag Node click distance or Pane click distance to 0 and even the slightest wobble stops being a click; raise them and longer slips still count.
  • Raise Drag threshold to the node click distance: now a small wobble neither moves the node nor stops being a click - the node only moves once the press is clearly a drag.

How it works

  • NodeClickDistance (3 px by default; 20 here) is how far the pointer may travel during a press on a node and still raise OnNodeClick with the BlowNode on release.
  • PaneClickDistance (3 px; 20 here) does the same for OnPaneClick on the empty pane, which carries the MouseEventArgs. Past it the press was a pan, and a click that would also have cleared the selection does nothing.
  • NodeDragThreshold (1 px) is how far the pointer must travel before the node starts to follow it. It is independent of the click distance, so with the defaults a press that moves 2 px both moves the node and is a click.
  • All three are measured in screen pixels, so they feel the same at any zoom.
  • OnNodeDragStart and OnNodeDragStop are raised for every press on a draggable node, moved or not; the page compares the node's Position between the two to count the presses that actually moved it.
An unhandled error has occurred. Reload 🗙