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

Class Mouse

src/main/java/fieldbox/boxes/Mouse.java:18–214  ·  view source on GitHub ↗

Entry-point from GLFW based Window.Event into Field. Boxes can add to properties "onMouseDown", "onMouseMove", "onMouseEnter" and "onMouseExit" to listen to these events. Optionally these can return Draggers that will continue to be notified until corresponding mouse up events

Source from the content-addressed store, hash-verified

16 * corresponding mouse up events.
17 */
18public class Mouse {
19
20 static public final Dict.Prop<Map<String, OnMouseDown>> onMouseDown = new Dict.Prop<>("onMouseDown").type()
21 .toCanon()
22 .autoConstructs(() -> new IdempotencyMap<>(OnMouseDown.class));
23 static public final Dict.Prop<Map<String, OnDoubleClick>> onDoubleClick = new Dict.Prop<>("onDoubleClick").type()
24 .toCanon()
25 .autoConstructs(() -> new IdempotencyMap<>(OnDoubleClick.class));
26 static public final Dict.Prop<Map<String, OnMouseMove>> onMouseMove = new Dict.Prop<>("onMouseMove").type()
27 .toCanon()
28 .autoConstructs(() -> new IdempotencyMap<>(OnMouseMove.class));
29 static public final Dict.Prop<Map<String, OnMouseEnter>> onMouseEnter = new Dict.Prop<>("onMouseEnter").type()
30 .toCanon()
31 .autoConstructs(() -> new IdempotencyMap<>(OnMouseEnter.class));
32 static public final Dict.Prop<Map<String, OnMouseScroll>> onMouseScroll = new Dict.Prop<>("onMouseScroll").type()
33 .toCanon()
34 .autoConstructs(() -> new IdempotencyMap<>(OnMouseScroll.class));
35 static public final Dict.Prop<Map<String, OnMouseExit>> onMouseExit = new Dict.Prop<>("onMouseExit").type()
36 .toCanon()
37 .autoConstructs(() -> new IdempotencyMap<>(OnMouseExit.class));
38 static public final Dict.Prop<Boolean> isSelected = new Dict.Prop<>("isSelected").type()
39 .toCanon();
40 static public final Dict.Prop<Boolean> isManipulated = new Dict.Prop<>("isManipulated").type()
41 .toCanon();
42 static public final Dict.Prop<Boolean> isSticky = new Dict.Prop<>("isSticky").type()
43 .toCanon();
44
45 static public final Dict.Prop<Integer> clickNumber= new Dict.Prop<>("clickNumber").type()
46 .toCanon();
47 static public final Dict.Prop<Box> originatesAt= new Dict.Prop<>("originatesAt").type()
48 .toCanon();
49
50 Map<Integer, Collection<Dragger>> ongoingDrags = new HashMap<Integer, Collection<Dragger>>();
51
52 Box lastStartAt = null;
53 long lastStartAtTime = 0;
54 int click = 0;
55
56 public void dispatch(Box root, Window.Event<Window.MouseState> event) {
57
58 Optional<Drawing> drawing = root.find(Drawing.drawing, root.both())
59 .findFirst();
60 if (drawing.isPresent())
61 {
62 fixDrawingSpace(drawing, event.after);
63 fixDrawingSpace(drawing, event.before);
64 }
65
66 Box startAt = Intersects.startAt(event.after, root);
67
68 event.properties.put(originatesAt, startAt);
69
70 Set<Integer> pressed = Window.MouseState.buttonsPressed(event.before, event.after);
71 Set<Integer> released = Window.MouseState.buttonsReleased(event.before, event.after);
72 Set<Integer> down = event.after.buttonsDown;
73
74 if (pressed.size()==1) {
75 if (startAt == lastStartAt && System.currentTimeMillis() - lastStartAtTime < 300) {

Callers

nothing calls this directly

Calls 3

autoConstructsMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected