Skip to content

Commit ff92a7a

Browse files
committed
fix focus problem for macos
1 parent 62d935d commit ff92a7a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

py5_jar/src/main/java/py5/core/Sketch.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ public void setup() {
190190
if (success) {
191191
PSurface surface = getSurface();
192192

193-
// request focus for Java2D renderer on Windows and MacOS
194-
if (platform == WINDOWS && sketchRenderer().equals(JAVA2D)) {
193+
// request focus for Java2D and FX2D renderers on Windows and MacOS
194+
if (platform == WINDOWS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D))) {
195195
Canvas canvas = (Canvas) surface.getNative();
196196
canvas.setFocusable(true);
197197
canvas.requestFocus();
198-
} else if (platform == MACOS && (sketchRenderer().equals(JAVA2D) || g.isGL())) {
198+
} else if (platform == MACOS && (sketchRenderer().equals(JAVA2D) || sketchRenderer().equals(FX2D) || g.isGL())) {
199199
ThinkDifferent.activateSketchWindow();
200200
}
201201

@@ -261,7 +261,8 @@ public void draw() {
261261
}
262262

263263
if (frameCount == 1 && platform == LINUX && g.isGL()) {
264-
// Linux with KDE Plasma window manager and OpenGL need to capture pixels after the last draw() call
264+
// Linux with KDE Plasma window manager and OpenGL need to capture pixels after
265+
// the last draw() call
265266
capturePixels();
266267
}
267268
}

0 commit comments

Comments
 (0)