(Box root, Window.Event<Window.KeyboardState> event)
| 45 | Set<Integer> released = Window.KeyboardState.keysReleased(event.before, event.after); |
| 46 | Set<Integer> down = event.after.keysDown; |
| 47 | |
| 48 | released.stream().map(r -> ongoingDrags.remove(r)).filter(x -> x != null).forEach(drags -> { |
| 49 | drags.stream().forEach(Hold -> Hold.update(event, true)); |
| 50 | drags.clear(); |
| 51 | }); |
| 52 | |
| 53 | for (Collection<Hold> d : ongoingDrags.values()) { |
| 54 | Iterator<Hold> dd = d.iterator(); |
| 55 | while (dd.hasNext()) { |
| 56 | Hold Hold = dd.next(); |
| 57 | boolean cont = false; |
| 58 | try { |
| 59 | cont = Hold.update(event, false); |
| 60 | } catch (Throwable t) { |
| 61 | System.err.println(" Exception thrown in Hold update :" + t); |
| 62 | System.err.println(" Hold will not be called again"); |
| 63 | cont = false; |
| 64 | } |
| 65 | if (!cont) dd.remove(); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | Box focused = root.find(KeyboardFocus._keyboardFocus, root.both()).map(x -> x.getFocus()).findFirst().orElseGet(() -> Optional.empty()).orElseGet(() -> root); |
| 70 | |
| 71 | Util.Errors errors = new Util.Errors(); |
| 72 | pressed.stream().forEach(p -> { |
| 73 | Collection<Hold> hold = ongoingDrags.computeIfAbsent(p, (x) -> new ArrayList<>()); |
| 74 | |
| 75 | // change map to handle errors on x |
| 76 | |
| 77 | focused.find(onKeyDown, root.both()) |
| 78 | .flatMap(x -> x.values() |
| 79 | .stream()) |
| 80 | .map(Util.wrap(x -> x.onKeyDown(event, p), errors, null, Hold.class)) |
| 81 | .filter(x -> x != null) |
| 82 | .collect(Collectors.toCollection(() -> hold)); |
| 83 | }); |
| 84 | |
| 85 | typed.stream().forEach(p -> { |
| 86 | focused.find(onCharTyped, root.both()).flatMap(x -> x.values().stream()).forEach(x -> x.onCharTyped(event, p)); |
| 87 | }); |
| 88 | if (errors.hasErrors()) { |
| 89 | errors.getErrors() |
| 90 | .forEach(x -> { |
| 91 | x.first.printStackTrace(); |
| 92 | }); |
| 93 | } |
| 94 | |
| 95 | } |
| 96 | } |
no test coverage detected