discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

onKey method

  1. @override
KeyEventResult onKey(
  1. KeyEvent event,
  2. ToolContext ctx
)
inherited

Implementation

@override
KeyEventResult onKey(KeyEvent event, ToolContext ctx) {
  final key = event.logicalKey;
  if ((key == LogicalKeyboardKey.shiftLeft ||
          key == LogicalKeyboardKey.shiftRight) &&
      event is! KeyRepeatEvent) {
    _lastShift = event is KeyDownEvent;
    if (_hoverVisible) _reresolve(ctx);
  }
  if (event is KeyUpEvent || !isPending) return KeyEventResult.ignored;
  if (event is KeyDownEvent) {
    if (key == LogicalKeyboardKey.escape) {
      cancel(ctx);
      return KeyEventResult.handled;
    }
    if (key == LogicalKeyboardKey.enter ||
        key == LogicalKeyboardKey.numpadEnter) {
      finish(ctx);
      _syncCamera(ctx);
      notifyListeners();
      return KeyEventResult.handled;
    }
    // Ruling F-2 (spec 05 D3, amended at execution): F3 (object snap) and
    // F (Fill), with no modifier held, bubble to the shell even mid-shape.
    // Neither ever touches the document, so the reason D3 swallows every
    // other key-down -- keeping undo and redo off a half-placed shape --
    // does not apply to them, and F3 is otherwise unreachable while a
    // polyline is pending.
    if ((key == LogicalKeyboardKey.f3 || key == LogicalKeyboardKey.keyF) &&
        !_hasModifier()) {
      return KeyEventResult.ignored;
    }
  }
  // Every other key-down and repeat mid-shape: undo and redo never land
  // on a half-placed shape (spec 05 D3, as 03 D5 during a drag).
  return KeyEventResult.handled;
}