Skip to content

Commit 4040f07

Browse files
committed
Small example optimization
1 parent be66704 commit 4040f07

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

imgui-lwjgl3/src/test/java/ImGuiGlfwExample.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,13 @@ private void initImGui() {
205205
});
206206

207207
glfwSetMouseButtonCallback(windowPtr, (w, button, action, mods) -> {
208-
final boolean[] mouseDown = new boolean[5];
208+
io.setMouseDown(0, button == GLFW_MOUSE_BUTTON_1 && action != GLFW_RELEASE);
209+
io.setMouseDown(1, button == GLFW_MOUSE_BUTTON_2 && action != GLFW_RELEASE);
210+
io.setMouseDown(2, button == GLFW_MOUSE_BUTTON_3 && action != GLFW_RELEASE);
211+
io.setMouseDown(3, button == GLFW_MOUSE_BUTTON_4 && action != GLFW_RELEASE);
212+
io.setMouseDown(4, button == GLFW_MOUSE_BUTTON_5 && action != GLFW_RELEASE);
209213

210-
mouseDown[0] = button == GLFW_MOUSE_BUTTON_1 && action != GLFW_RELEASE;
211-
mouseDown[1] = button == GLFW_MOUSE_BUTTON_2 && action != GLFW_RELEASE;
212-
mouseDown[2] = button == GLFW_MOUSE_BUTTON_3 && action != GLFW_RELEASE;
213-
mouseDown[3] = button == GLFW_MOUSE_BUTTON_4 && action != GLFW_RELEASE;
214-
mouseDown[4] = button == GLFW_MOUSE_BUTTON_5 && action != GLFW_RELEASE;
215-
216-
io.setMouseDown(mouseDown);
217-
218-
if (!io.getWantCaptureMouse() && mouseDown[1]) {
214+
if (!io.getWantCaptureMouse() && io.getMouseDown(1)) {
219215
ImGui.setWindowFocus(null);
220216
}
221217
});

0 commit comments

Comments
 (0)