diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java index 02a5319e7f3..1c32a746d17 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java @@ -244,6 +244,10 @@ public void setBoundsSize(NSSize newSize) { OS.objc_msgSend(this.id, OS.sel_setBoundsSize_, newSize); } +public void setClipsToBounds(boolean clipsToBounds) { + OS.objc_msgSend(this.id, OS.sel_setClipsToBounds_, clipsToBounds); +} + public void setFocusRingType(long focusRingType) { OS.objc_msgSend(this.id, OS.sel_setFocusRingType_, focusRingType); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index 873c785a1ed..a33aa208419 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -162,6 +162,9 @@ public static int VERSION (int major, int minor, int bugfix) { public static final long class_NSToolbarView = objc_getClass("NSToolbarView"); + /** Since macOS 14 the clipsToBounds property of NSView is exposed */ + public static final long sel_setClipsToBounds_ = Selector.sel_setClipsToBounds_.value; + /* * Wrapper function which will call NSSavePanel.beginSheetModalForWindow. This * implementation allows passing of objective-C block from Java to C code, and diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java index 42425a680d0..d257f420325 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java @@ -84,6 +84,9 @@ public enum Selector { , sel_awtAppDelegate("awtAppDelegate") + /** Since macOS 14 the clipsToBounds property of NSView is exposed */ + , sel_setClipsToBounds_("setClipsToBounds:") + /** This section is auto generated */ , sel_CGEvent("CGEvent") diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java index 0280dd411f2..c5c26d69a01 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java @@ -759,6 +759,13 @@ void drawRect (long id, long sel, NSRect rect) { if (!isDrawing()) return; Display display = this.display; NSView view = new NSView(id); + + /* + * Since macOS 14 the clipsToBounds property of NSView has to be set to true + * See https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-14 + */ + view.setClipsToBounds(true); + display.isPainting.addObject(view); NSGraphicsContext context = NSGraphicsContext.currentContext(); context.saveGraphicsState();