From 6bef4a3db073d81d1b31b93dbdee2639044d0e9d Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Mon, 20 Jul 2026 19:45:46 +0200 Subject: [PATCH] [Cocoa] Replace deprecated Alert Style and Event Modifier Flag constants The macOS AppKit framework deprecated the old-style NSAlert alert style constants in macOS 10.12 (Sierra) in favour of the NSAlertStyle enum, and the old-style NSEvent modifier flag constants in macOS 10.12 in favour of the NSEventModifierFlags option set type. This change replaces all seven deprecated constants throughout the SWT macOS/Cocoa implementation with their modern equivalents, eliminating compiler deprecation warnings and improving forward compatibility with future macOS SDK versions. Replaced constants (values are unchanged): NSWarningAlertStyle -> NSAlertStyleWarning (0) NSInformationalAlertStyle -> NSAlertStyleInformational (1) NSCriticalAlertStyle -> NSAlertStyleCritical (2) NSShiftKeyMask -> NSEventModifierFlagShift (131072) NSControlKeyMask -> NSEventModifierFlagControl (262144) NSCommandKeyMask -> NSEventModifierFlagCommand (1048576) NSHelpKeyMask -> NSEventModifierFlagHelp (4194304) Contributes to https://github.com/eclipse-platform/eclipse.platform.swt/issues/3214 --- .../cocoa/org/eclipse/swt/dnd/DropTarget.java | 2 +- .../swt/internal/cocoa/AppKitFull.bridgesupport | 14 +++++++------- .../internal/cocoa/AppKitFull.bridgesupport.extras | 14 +++++++------- .../cocoa/org/eclipse/swt/internal/cocoa/OS.java | 14 +++++++------- .../cocoa/org/eclipse/swt/widgets/Combo.java | 8 ++++---- .../cocoa/org/eclipse/swt/widgets/Control.java | 14 +++++++------- .../cocoa/org/eclipse/swt/widgets/Display.java | 12 ++++++------ .../cocoa/org/eclipse/swt/widgets/Link.java | 2 +- .../cocoa/org/eclipse/swt/widgets/Menu.java | 2 +- .../cocoa/org/eclipse/swt/widgets/MenuItem.java | 12 ++++++------ .../cocoa/org/eclipse/swt/widgets/MessageBox.java | 8 ++++---- .../cocoa/org/eclipse/swt/widgets/Sash.java | 2 +- .../cocoa/org/eclipse/swt/widgets/Shell.java | 2 +- .../cocoa/org/eclipse/swt/widgets/Table.java | 4 ++-- .../cocoa/org/eclipse/swt/widgets/Text.java | 6 +++--- .../cocoa/org/eclipse/swt/widgets/Tracker.java | 8 ++++---- .../cocoa/org/eclipse/swt/widgets/TrayItem.java | 2 +- .../cocoa/org/eclipse/swt/widgets/Tree.java | 4 ++-- .../cocoa/org/eclipse/swt/widgets/Widget.java | 6 +++--- 19 files changed, 68 insertions(+), 68 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java index c9df3a4b9f5..d327f475414 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java @@ -575,7 +575,7 @@ int getOperationFromKeyState() { if (currEvent != null) { long modifiers = currEvent.modifierFlags(); boolean option = (modifiers & OS.NSAlternateKeyMask) == OS.NSAlternateKeyMask; - boolean control = (modifiers & OS.NSControlKeyMask) == OS.NSControlKeyMask; + boolean control = (modifiers & OS.NSEventModifierFlagControl) == OS.NSEventModifierFlagControl; if (control && option) return DND.DROP_DEFAULT; if (control) return DND.DROP_LINK; if (option) return DND.DROP_COPY; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport index c9b09006ac9..5466b7020c6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport @@ -1198,6 +1198,9 @@ + + + @@ -1421,7 +1424,6 @@ - @@ -1466,7 +1468,6 @@ - @@ -1477,7 +1478,6 @@ - @@ -1545,6 +1545,10 @@ + + + + @@ -1726,7 +1730,6 @@ - @@ -1783,7 +1786,6 @@ - @@ -2207,7 +2209,6 @@ - @@ -2522,7 +2523,6 @@ - diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras index 512bd54578f..18d835f349f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras @@ -4373,6 +4373,9 @@ + + + @@ -4405,20 +4408,17 @@ - - - @@ -4433,6 +4433,10 @@ + + + + @@ -4449,7 +4453,6 @@ - @@ -4465,7 +4468,6 @@ - @@ -4525,7 +4527,6 @@ - @@ -4562,7 +4563,6 @@ - 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 13bbe204d10..ea852de5a13 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 @@ -2144,6 +2144,9 @@ public static Selector getSelector (long value) { /** Constants */ public static final int NSAlertFirstButtonReturn = 1000; public static final int NSAlertSecondButtonReturn = 1001; +public static final int NSAlertStyleCritical = 2; +public static final int NSAlertStyleInformational = 1; +public static final int NSAlertStyleWarning = 0; public static final int NSAlertThirdButtonReturn = 1002; public static final int NSAlphaFirstBitmapFormat = 1; public static final int NSAlphaNonpremultipliedBitmapFormat = 2; @@ -2176,14 +2179,11 @@ public static Selector getSelector (long value) { public static final int NSCarriageReturnCharacter = 13; public static final int NSClosePathBezierPathElement = 3; public static final int NSColorSpaceModelRGB = 1; -public static final int NSCommandKeyMask = 1048576; public static final int NSCompositingOperationClear = 0; public static final int NSCompositingOperationCopy = 1; public static final int NSCompositingOperationSourceAtop = 5; public static final int NSCompositingOperationSourceOver = 2; public static final int NSContentsCellMask = 1; -public static final int NSControlKeyMask = 262144; -public static final int NSCriticalAlertStyle = 2; public static final int NSCurveToBezierPathElement = 2; public static final int NSDatePickerStyleClockAndCalendar = 1; public static final int NSDatePickerStyleTextField = 2; @@ -2198,6 +2198,10 @@ public static Selector getSelector (long value) { public static final int NSDragOperationNone = 0; public static final int NSEnterCharacter = 3; public static final int NSEvenOddWindingRule = 1; +public static final int NSEventModifierFlagCommand = 1048576; +public static final int NSEventModifierFlagControl = 262144; +public static final int NSEventModifierFlagHelp = 4194304; +public static final int NSEventModifierFlagShift = 131072; public static final int NSEventPhaseBegan = 1; public static final int NSEventPhaseCancelled = 16; public static final int NSEventPhaseEnded = 8; @@ -2214,7 +2218,6 @@ public static Selector getSelector (long value) { public static final int NSFontPanelModeMaskAllEffects = 1048320; public static final int NSFontPanelModeMaskAllModes = -1; public static final int NSHelpFunctionKey = 63302; -public static final int NSHelpKeyMask = 4194304; public static final int NSHourMinuteDatePickerElementFlag = 12; public static final int NSHourMinuteSecondDatePickerElementFlag = 14; public static final int NSImageAbove = 5; @@ -2230,7 +2233,6 @@ public static Selector getSelector (long value) { public static final int NSImageOnly = 1; public static final int NSImageOverlaps = 6; public static final int NSImageScaleNone = 2; -public static final int NSInformationalAlertStyle = 1; public static final int NSItalicFontMask = 1; public static final int NSKeyDown = 10; public static final int NSKeyUp = 11; @@ -2296,7 +2298,6 @@ public static Selector getSelector (long value) { public static final int NSScrollerKnobSlot = 6; public static final int NSScrollerStyleLegacy = 0; public static final int NSScrollerStyleOverlay = 1; -public static final int NSShiftKeyMask = 131072; public static final int NSSquareLineCapStyle = 2; public static final int NSStatusWindowLevel = 25; public static final int NSStringDrawingUsesLineFragmentOrigin = 1; @@ -2333,7 +2334,6 @@ public static Selector getSelector (long value) { public static final int NSViewMinXMargin = 1; public static final int NSViewMinYMargin = 8; public static final int NSViewWidthSizable = 2; -public static final int NSWarningAlertStyle = 0; public static final int NSWindowAbove = 1; public static final int NSWindowBelow = -1; public static final int NSWindowCollectionBehaviorFullScreenAuxiliary = 256; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java index 0597becb231..76e216736d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java @@ -1445,9 +1445,9 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) { int stateMask = 0; long modifierFlags = nsEvent.modifierFlags(); if ((modifierFlags & OS.NSAlternateKeyMask) != 0) stateMask |= SWT.ALT; - if ((modifierFlags & OS.NSShiftKeyMask) != 0) stateMask |= SWT.SHIFT; - if ((modifierFlags & OS.NSControlKeyMask) != 0) stateMask |= SWT.CONTROL; - if ((modifierFlags & OS.NSCommandKeyMask) != 0) stateMask |= SWT.COMMAND; + if ((modifierFlags & OS.NSEventModifierFlagShift) != 0) stateMask |= SWT.SHIFT; + if ((modifierFlags & OS.NSEventModifierFlagControl) != 0) stateMask |= SWT.CONTROL; + if ((modifierFlags & OS.NSEventModifierFlagCommand) != 0) stateMask |= SWT.COMMAND; if (type != SWT.KeyDown) return result; short keyCode = nsEvent.keyCode (); if (stateMask == SWT.COMMAND) { @@ -1484,7 +1484,7 @@ boolean sendTrackingKeyEvent (NSEvent nsEvent, int type) { * queue. */ long modifiers = nsEvent.modifierFlags(); - if ((modifiers & OS.NSShiftKeyMask) == 0) { + if ((modifiers & OS.NSEventModifierFlagShift) == 0) { short keyCode = nsEvent.keyCode (); switch (keyCode) { case 125: /* Arrow Down */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java index 8c2238e83cf..f28f96b24da 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java @@ -1044,7 +1044,7 @@ void doCommandBySelector (long id, long sel, long selector) { * is down, because we likely triggered the current key sequence via flagsChanged. */ long modifiers = nsEvent.modifierFlags(); - if (s.keyInputHappened == false || (modifiers & OS.NSCommandKeyMask) != 0) { + if (s.keyInputHappened == false || (modifiers & OS.NSEventModifierFlagCommand) != 0) { s.keyInputHappened = true; boolean [] consume = new boolean [1]; if (translateTraversal (nsEvent.keyCode (), nsEvent, consume)) return; @@ -1363,9 +1363,9 @@ void flagsChanged (long id, long sel, long theEvent) { int keyCode = Display.translateKey (nsEvent.keyCode ()); switch (keyCode) { case SWT.ALT: mask = OS.NSAlternateKeyMask; break; - case SWT.CONTROL: mask = OS.NSControlKeyMask; break; - case SWT.COMMAND: mask = OS.NSCommandKeyMask; break; - case SWT.SHIFT: mask = OS.NSShiftKeyMask; break; + case SWT.CONTROL: mask = OS.NSEventModifierFlagControl; break; + case SWT.COMMAND: mask = OS.NSEventModifierFlagCommand; break; + case SWT.SHIFT: mask = OS.NSEventModifierFlagShift; break; case SWT.CAPS_LOCK: Event event = new Event(); event.keyCode = keyCode; @@ -2558,7 +2558,7 @@ boolean mouseEvent (long id, long sel, long theEvent, int type) { switch (nsType) { case OS.NSLeftMouseDown: - if (nsEvent.clickCount() == 1 && (nsEvent.modifierFlags() & OS.NSControlKeyMask) == 0 && (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) { + if (nsEvent.clickCount() == 1 && (nsEvent.modifierFlags() & OS.NSEventModifierFlagControl) == 0 && (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) { consume = new boolean[1]; NSPoint location = view.convertPoint_fromView_(nsEvent.locationInWindow(), null); if (!view.isFlipped ()) { @@ -4783,7 +4783,7 @@ boolean translateTraversal (int key, NSEvent theEvent, boolean [] consume) { } case 48: /* Tab */ { long modifiers = theEvent.modifierFlags (); - boolean next = (modifiers & OS.NSShiftKeyMask) == 0; + boolean next = (modifiers & OS.NSEventModifierFlagShift) == 0; detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS; break; } @@ -4799,7 +4799,7 @@ boolean translateTraversal (int key, NSEvent theEvent, boolean [] consume) { case 121: /* Page down */ { all = true; long modifiers = theEvent.modifierFlags (); - if ((modifiers & OS.NSControlKeyMask) == 0) return false; + if ((modifiers & OS.NSEventModifierFlagControl) == 0) return false; detail = key == 121 /* Page down */ ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS; break; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index 25f78cbc179..c2524f8e8c9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -1103,7 +1103,7 @@ void createMainMenu () { title = NSString.stringWith(SWT.getMessage("SWT_HideOthers")); menuItem = appleMenu.addItemWithTitle(title, OS.sel_hideOtherApplications_, NSString.stringWith("h")); - menuItem.setKeyEquivalentModifierMask(OS.NSCommandKeyMask | OS.NSAlternateKeyMask); + menuItem.setKeyEquivalentModifierMask(OS.NSEventModifierFlagCommand | OS.NSAlternateKeyMask); menuItem.setTarget(applicationDelegate); title = NSString.stringWith(SWT.getMessage("SWT_ShowAll")); @@ -3924,9 +3924,9 @@ boolean performKeyEquivalent(NSWindow window, NSEvent nsEvent) { long selector = 0; long modifierFlags = nsEvent.modifierFlags(); if ((modifierFlags & OS.NSAlternateKeyMask) != 0) stateMask |= SWT.ALT; - if ((modifierFlags & OS.NSShiftKeyMask) != 0) stateMask |= SWT.SHIFT; - if ((modifierFlags & OS.NSControlKeyMask) != 0) stateMask |= SWT.CONTROL; - if ((modifierFlags & OS.NSCommandKeyMask) != 0) stateMask |= SWT.COMMAND; + if ((modifierFlags & OS.NSEventModifierFlagShift) != 0) stateMask |= SWT.SHIFT; + if ((modifierFlags & OS.NSEventModifierFlagControl) != 0) stateMask |= SWT.CONTROL; + if ((modifierFlags & OS.NSEventModifierFlagCommand) != 0) stateMask |= SWT.COMMAND; if (stateMask == SWT.COMMAND) { short keyCode = nsEvent.keyCode (); switch (keyCode) { @@ -5679,7 +5679,7 @@ void applicationSendEvent (long id, long sel, long event) { * Feature in Cocoa. The help key triggers context-sensitive help but doesn't get forwarded to the window as a key event. * If the event is destined for the key window, is the help key, and is an NSKeyDown, send it directly to the window first. */ - if (window != null && window.isKeyWindow() && nsEvent.type() == OS.NSKeyDown && (nsEvent.modifierFlags() & OS.NSHelpKeyMask) != 0) { + if (window != null && window.isKeyWindow() && nsEvent.type() == OS.NSKeyDown && (nsEvent.modifierFlags() & OS.NSEventModifierFlagHelp) != 0) { window.sendEvent(nsEvent); } @@ -5687,7 +5687,7 @@ void applicationSendEvent (long id, long sel, long event) { * Feature in Cocoa. NSKeyUp events are not delivered to the window if the command key is down. * If the event is destined for the key window, and it's a key up and the command key is down, send it directly to the window. */ - if (window != null && window.isKeyWindow() && nsEvent.type() == OS.NSKeyUp && (nsEvent.modifierFlags() & OS.NSCommandKeyMask) != 0) { + if (window != null && window.isKeyWindow() && nsEvent.type() == OS.NSKeyUp && (nsEvent.modifierFlags() & OS.NSEventModifierFlagCommand) != 0) { window.sendEvent(nsEvent); } else { objc_super super_struct = new objc_super (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java index 6d075f0136a..c1f1fd465a7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java @@ -824,7 +824,7 @@ int traversalCode (int key, NSEvent theEvent) { int bits = super.traversalCode (key, theEvent); if (key == 48 /* Tab */ && theEvent != null) { long modifierFlags = theEvent.modifierFlags(); - boolean next = (modifierFlags & OS.NSShiftKeyMask) == 0; + boolean next = (modifierFlags & OS.NSEventModifierFlagShift) == 0; if (next && focusIndex < offsets.length - 1) { return bits & ~ SWT.TRAVERSE_TAB_NEXT; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java index 2bdf5da08c8..9c5bbfab320 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java @@ -389,7 +389,7 @@ void createItem (MenuItem item, int index) { long keyEquiv = 0; if (keyEquivString != null) { keyEquiv = keyEquivString.characterAtIndex(0); - if ((keyMask & OS.NSCommandKeyMask) != 0) keyEquiv |= SWT.COMMAND; + if ((keyMask & OS.NSEventModifierFlagCommand) != 0) keyEquiv |= SWT.COMMAND; if ((keyMask & OS.NSAlternateKeyMask) != 0) keyEquiv |= SWT.ALT; item.accelerator = (int) keyEquiv; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java index 512ef0ab5ca..5ddd1191c6d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MenuItem.java @@ -623,9 +623,9 @@ public void setAccelerator (int accelerator) { nsItem.setKeyEquivalent (nsstring.lowercaseString()); nsstring.release(); int mask = 0; - if ((accelerator & SWT.SHIFT) != 0) mask |= OS.NSShiftKeyMask; - if ((accelerator & SWT.CONTROL) != 0) mask |= OS.NSControlKeyMask; - if ((accelerator & SWT.COMMAND) != 0) mask |= OS.NSCommandKeyMask; + if ((accelerator & SWT.SHIFT) != 0) mask |= OS.NSEventModifierFlagShift; + if ((accelerator & SWT.CONTROL) != 0) mask |= OS.NSEventModifierFlagControl; + if ((accelerator & SWT.COMMAND) != 0) mask |= OS.NSEventModifierFlagCommand; if ((accelerator & SWT.ALT) != 0) mask |= OS.NSAlternateKeyMask; nsItem.setKeyEquivalentModifierMask (mask); } @@ -951,10 +951,10 @@ boolean updateAccelerator (boolean show) { if (i < buffer.length && buffer [i] == '\t') { for (j = i + 1; j < buffer.length; j++) { switch (buffer [j]) { - case '\u2303': mask |= OS.NSControlKeyMask; i++; break; + case '\u2303': mask |= OS.NSEventModifierFlagControl; i++; break; case '\u2325': mask |= OS.NSAlternateKeyMask; i++; break; - case '\u21E7': mask |= OS.NSShiftKeyMask; i++; break; - case '\u2318': mask |= OS.NSCommandKeyMask; i++; break; + case '\u21E7': mask |= OS.NSEventModifierFlagShift; i++; break; + case '\u2318': mask |= OS.NSEventModifierFlagCommand; i++; break; default: j = buffer.length; break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java index 53684bcb4d2..2358dc0186b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/MessageBox.java @@ -151,16 +151,16 @@ public String getMessage () { */ public int open () { NSAlert alert = (NSAlert) new NSAlert().alloc().init(); - int alertType = OS.NSInformationalAlertStyle; + int alertType = OS.NSAlertStyleInformational; if ((style & SWT.ICON_ERROR) != 0) { - alertType = OS.NSCriticalAlertStyle; + alertType = OS.NSAlertStyleCritical; } if (((style & SWT.ICON_INFORMATION) != 0) || ((style & SWT.ICON_WORKING) != 0) || ((style & SWT.ICON_QUESTION) != 0)) { - alertType = OS.NSInformationalAlertStyle; + alertType = OS.NSAlertStyleInformational; alert.setIcon(NSImage.imageNamed(OS.NSImageNameInfo)); } if ((style & SWT.ICON_WARNING) != 0) { - alertType = OS.NSWarningAlertStyle; + alertType = OS.NSAlertStyleWarning; alert.setIcon(NSImage.imageNamed(OS.NSImageNameCaution)); } alert.setAlertStyle(alertType); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java index e9792688bc5..200a9ec1e98 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java @@ -305,7 +305,7 @@ boolean sendKeyEvent(NSEvent nsEvent, int type) { int xChange = 0, yChange = 0; int stepSize = PAGE_INCREMENT; long modifiers = nsEvent.modifierFlags(); - if ((modifiers & OS.NSControlKeyMask) != 0) stepSize = INCREMENT; + if ((modifiers & OS.NSEventModifierFlagControl) != 0) stepSize = INCREMENT; if ((style & SWT.VERTICAL) != 0) { if (keyCode == 126 || keyCode == 125) break; xChange = keyCode == 123 ? -stepSize : stepSize; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 9ef9aa678ea..0029ba4b3bb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -2515,7 +2515,7 @@ void windowSendEvent (long id, long sel, long event) { * swallowed to handle native traversal. If we find that, force the key event to * the first responder. */ - if ((nsEvent.modifierFlags() & OS.NSControlKeyMask) != 0) { + if ((nsEvent.modifierFlags() & OS.NSEventModifierFlagControl) != 0) { NSString chars = nsEvent.characters(); if (chars != null && chars.length() == 1) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java index 49549fcf9ca..5d6825ec32a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java @@ -258,7 +258,7 @@ boolean canDragRowsWithIndexes_atPoint(long id, long sel, long rowIndexes, NSPoi boolean drag = (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect); if (drag) { - if (!widget.isRowSelected(row) && (modifiers & (OS.NSCommandKeyMask | OS.NSShiftKeyMask | OS.NSAlternateKeyMask)) == 0) { + if (!widget.isRowSelected(row) && (modifiers & (OS.NSEventModifierFlagCommand | OS.NSEventModifierFlagShift | OS.NSAlternateKeyMask)) == 0) { NSIndexSet set = (NSIndexSet)new NSIndexSet().alloc(); set = set.initWithIndex(row); widget.selectRowIndexes (set, false); @@ -2080,7 +2080,7 @@ void mouseDown (long id, long sel, long theEvent) { // which is interpreted as a single click that clears the selection. Fix is to ignore control-click if the // view has a context menu. NSEvent event = new NSEvent(theEvent); - if ((event.modifierFlags() & OS.NSControlKeyMask) != 0) return; + if ((event.modifierFlags() & OS.NSEventModifierFlagControl) != 0) return; } super.mouseDown(id, sel, theEvent); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java index ee965adcccd..17fd2df1630 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java @@ -1714,7 +1714,7 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) { if (!result) return result; if (type != SWT.KeyDown) return result; long modifierFlags = nsEvent.modifierFlags(); - if ((modifierFlags & OS.NSCommandKeyMask) != 0) { + if ((modifierFlags & OS.NSEventModifierFlagCommand) != 0) { short keyCode = nsEvent.keyCode (); switch (keyCode) { case 7: /* X */ @@ -2460,8 +2460,8 @@ int traversalCode (int key, NSEvent theEvent) { bits &= ~SWT.TRAVERSE_RETURN; if (key == 48 /* Tab */ && theEvent != null) { long modifiers = theEvent.modifierFlags (); - boolean next = (modifiers & OS.NSShiftKeyMask) == 0; - if (next && (modifiers & OS.NSControlKeyMask) == 0) { + boolean next = (modifiers & OS.NSEventModifierFlagShift) == 0; + if (next && (modifiers & OS.NSEventModifierFlagControl) == 0) { bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java index aa8e2507e93..374a5f3c93d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java @@ -559,9 +559,9 @@ void key (NSEvent nsEvent) { int mask = 0; switch (keyCode) { case SWT.ALT: mask = OS.NSAlternateKeyMask; break; - case SWT.CONTROL: mask = OS.NSControlKeyMask; break; - case SWT.COMMAND: mask = OS.NSCommandKeyMask; break; - case SWT.SHIFT: mask = OS.NSShiftKeyMask; break; + case SWT.CONTROL: mask = OS.NSEventModifierFlagControl; break; + case SWT.COMMAND: mask = OS.NSEventModifierFlagCommand; break; + case SWT.SHIFT: mask = OS.NSEventModifierFlagShift; break; case SWT.CAPS_LOCK: Event event = new Event(); event.keyCode = keyCode; @@ -583,7 +583,7 @@ void key (NSEvent nsEvent) { } } - int stepSize = (modifierFlags & OS.NSControlKeyMask) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE; + int stepSize = (modifierFlags & OS.NSEventModifierFlagControl) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE; int xChange = 0, yChange = 0; switch (nsKeyCode) { case 53: /* Esc */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java index 00b271bfdf7..328e6139996 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java @@ -510,7 +510,7 @@ boolean shouldShowMenu (NSEvent event) { if (!(hooks(SWT.Selection) || hooks(SWT.DefaultSelection))) { return true; } - if ((event.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask) == OS.NSControlKeyMask) { + if ((event.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask) == OS.NSEventModifierFlagControl) { return true; } return false; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java index 0a92f0beb2f..4195ef69532 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java @@ -312,7 +312,7 @@ boolean canDragRowsWithIndexes_atPoint(long id, long sel, long rowIndexes, NSPoi boolean drag = (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect); if (drag) { - if (!widget.isRowSelected(row) && (modifiers & (OS.NSCommandKeyMask | OS.NSShiftKeyMask | OS.NSAlternateKeyMask | OS.NSControlKeyMask)) == 0) { + if (!widget.isRowSelected(row) && (modifiers & (OS.NSEventModifierFlagCommand | OS.NSEventModifierFlagShift | OS.NSAlternateKeyMask | OS.NSEventModifierFlagControl)) == 0) { NSIndexSet set = (NSIndexSet)new NSIndexSet().alloc(); set = set.initWithIndex(row); widget.selectRowIndexes (set, false); @@ -2133,7 +2133,7 @@ void mouseDown (long id, long sel, long theEvent) { // it from menuForEvent:. This has the side effect, however, of sending control-click to the NSTableView, // which is interpreted as a single click that clears the selection. Fix is to ignore control-click, NSEvent event = new NSEvent(theEvent); - if ((event.modifierFlags() & OS.NSControlKeyMask) != 0) return; + if ((event.modifierFlags() & OS.NSEventModifierFlagControl) != 0) return; } super.mouseDown(id, sel, theEvent); } 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 9e3b018b5f1..3804a64ecf6 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 @@ -1879,9 +1879,9 @@ boolean setInputState (Event event, NSEvent nsEvent, int type) { } long modifierFlags = nsEvent.modifierFlags(); if ((modifierFlags & OS.NSAlternateKeyMask) != 0) event.stateMask |= SWT.ALT; - if ((modifierFlags & OS.NSShiftKeyMask) != 0) event.stateMask |= SWT.SHIFT; - if ((modifierFlags & OS.NSControlKeyMask) != 0) event.stateMask |= SWT.CONTROL; - if ((modifierFlags & OS.NSCommandKeyMask) != 0) event.stateMask |= SWT.COMMAND; + if ((modifierFlags & OS.NSEventModifierFlagShift) != 0) event.stateMask |= SWT.SHIFT; + if ((modifierFlags & OS.NSEventModifierFlagControl) != 0) event.stateMask |= SWT.CONTROL; + if ((modifierFlags & OS.NSEventModifierFlagCommand) != 0) event.stateMask |= SWT.COMMAND; long state = NSEvent.pressedMouseButtons(); if ((state & 0x1) != 0) event.stateMask |= SWT.BUTTON1;