MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / dispatch

Method dispatch

src/main/java/fieldbox/boxes/Keyboard.java:47–104  ·  view source on GitHub ↗
(Box root, Window.Event<Window.KeyboardState> event)

Source from the content-addressed store, hash-verified

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}

Callers 1

installMethod · 0.95

Calls 15

updateMethod · 0.95
findMethod · 0.95
wrapMethod · 0.95
hasErrorsMethod · 0.95
getErrorsMethod · 0.95
charsPressedMethod · 0.80
keysReleasedMethod · 0.80
getFocusMethod · 0.80
emptyMethod · 0.80
computeIfAbsentMethod · 0.80
collectMethod · 0.80
toCollectionMethod · 0.80

Tested by

no test coverage detected