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

Method mouseButton

src/main/java/field/graphics/Windows.java:156–206  ·  view source on GitHub ↗
(long window, int button, int pressed, int mods)

Source from the content-addressed store, hash-verified

154 @Override
155 public void mouseButton(long window, int button, int pressed, int mods) {
156 if (button == 0 && mods == 2 && pressed != 0) {
157 button = 1;
158 mods = 0;
159 fakeButton1 = true;
160 } else if (button == 0 && pressed == 0 && fakeButton1) {
161 button = 1;
162 mods = 0;
163 fakeButton1 = false;
164 }
165
166 final int fbutton = button;
167 final int fmods = mods;
168
169
170 System.out.println(" -- mouse button "+window+" "+button+" "+pressed+" "+mods);
171
172 Runnable r = () -> {
173 checkClassLoader();
174
175
176 GlfwCallback a = adaptors.get(window);
177
178// // added, because mouse down doesn't report the mouse location correctly on first click in os X
179 // removed, because El Capitan reports getCursorPos in screen coords
180 if (Main.os == Main.OS.mac) {
181
182 double[] xp = {0.0};
183 double[] yp = {0.0};
184 glfwGetCursorPos(window, xp, yp);
185
186 System.out.println(" fake cursor pos at down is "+xp[0]+" "+yp[0]);
187
188 if (a != null)
189 a.cursorPos(window, xp[0], yp[0]);
190 }
191
192
193
194 if (a != null)
195 a.mouseButton(window, fbutton, pressed, fmods);
196 };
197
198 if (checkThread()) r.run();
199 else {
200 events.addLast(r);
201 RunLoop.main.shouldSleep.add(Windows.this);
202 RunLoop.main.interrupt();
203 }
204 }
205
206
207 @Override
208 public void scroll(long window, double scrollX, double scrollY) {
209 Runnable r = () -> {

Callers

nothing calls this directly

Calls 9

checkClassLoaderMethod · 0.95
cursorPosMethod · 0.95
mouseButtonMethod · 0.95
checkThreadMethod · 0.95
interruptMethod · 0.80
getMethod · 0.65
printlnMethod · 0.45
runMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected