Update deprecated macOS constants

This commit is contained in:
David Capello 2017-09-22 16:25:26 -03:00
parent 43db106db0
commit 3343485acf
4 changed files with 25 additions and 23 deletions

View File

@ -28,7 +28,7 @@ void OSXEventQueue::getEvent(Event& ev, bool canWait)
// Pump the whole queue of Cocoa events
NSEvent* event;
do {
event = [app nextEventMatchingMask:NSAnyEventMask
event = [app nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
dequeue:YES];
@ -37,7 +37,7 @@ void OSXEventQueue::getEvent(Event& ev, bool canWait)
// combinations, and send them directly to the main
// NSView. Without this, the NSApplication intercepts the key
// combination and use it to go to the next key view.
if (event.type == NSKeyDown) {
if (event.type == NSEventTypeKeyDown) {
[app.mainWindow.contentView keyDown:event];
}
else {
@ -49,7 +49,7 @@ void OSXEventQueue::getEvent(Event& ev, bool canWait)
if (!m_events.try_pop(ev)) {
if (canWait) {
// Wait until there is a Cocoa event in queue
[NSApp nextEventMatchingMask:NSAnyEventMask
[NSApp nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode
dequeue:NO];

View File

@ -55,13 +55,13 @@ Event::MouseButton get_mouse_buttons(NSEvent* event)
// Some Wacom drivers on OS X report right-clicks with
// buttonNumber=0, so we've to check the type event anyway.
switch (event.type) {
case NSLeftMouseDown:
case NSLeftMouseUp:
case NSLeftMouseDragged:
case NSEventTypeLeftMouseDown:
case NSEventTypeLeftMouseUp:
case NSEventTypeLeftMouseDragged:
return Event::LeftButton;
case NSRightMouseDown:
case NSRightMouseUp:
case NSRightMouseDragged:
case NSEventTypeRightMouseDown:
case NSEventTypeRightMouseUp:
case NSEventTypeRightMouseDragged:
return Event::RightButton;
}
@ -81,10 +81,10 @@ KeyModifiers get_modifiers_from_nsevent(NSEvent* event)
{
int modifiers = kKeyNoneModifier;
NSEventModifierFlags nsFlags = event.modifierFlags;
if (nsFlags & NSShiftKeyMask) modifiers |= kKeyShiftModifier;
if (nsFlags & NSControlKeyMask) modifiers |= kKeyCtrlModifier;
if (nsFlags & NSAlternateKeyMask) modifiers |= kKeyAltModifier;
if (nsFlags & NSCommandKeyMask) modifiers |= kKeyCmdModifier;
if (nsFlags & NSEventModifierFlagShift) modifiers |= kKeyShiftModifier;
if (nsFlags & NSEventModifierFlagControl) modifiers |= kKeyCtrlModifier;
if (nsFlags & NSEventModifierFlagOption) modifiers |= kKeyAltModifier;
if (nsFlags & NSEventModifierFlagCommand) modifiers |= kKeyCmdModifier;
if (osx_is_key_pressed(kKeySpace)) modifiers |= kKeySpaceModifier;
return (KeyModifiers)modifiers;
}
@ -262,10 +262,10 @@ using namespace she;
{
static int lastFlags = 0;
static int flags[] = {
NSShiftKeyMask,
NSControlKeyMask,
NSAlternateKeyMask,
NSCommandKeyMask
NSEventModifierFlagShift,
NSEventModifierFlagControl,
NSEventModifierFlagOption,
NSEventModifierFlagCommand
};
static KeyScancode scancodes[] = {
kKeyLShift,
@ -493,9 +493,9 @@ using namespace she;
{
if (event.isEnteringProximity == YES) {
switch (event.pointingDeviceType) {
case NSPenPointingDevice: m_pointerType = she::PointerType::Pen; break;
case NSCursorPointingDevice: m_pointerType = she::PointerType::Cursor; break;
case NSEraserPointingDevice: m_pointerType = she::PointerType::Eraser; break;
case NSPointingDeviceTypePen: m_pointerType = she::PointerType::Pen; break;
case NSPointingDeviceTypeCursor: m_pointerType = she::PointerType::Cursor; break;
case NSPointingDeviceTypeEraser: m_pointerType = she::PointerType::Eraser; break;
default:
m_pointerType = she::PointerType::Unknown;
break;

View File

@ -315,7 +315,7 @@ KeyScancode scancode_from_nsevent(NSEvent* event)
// For keys that are not in the numpad we try to get the scancode
// converting the first char in NSEvent.characters to a
// scancode.
if ((event.modifierFlags & NSNumericPadKeyMask) == 0) {
if ((event.modifierFlags & NSEventModifierFlagNumericPad) == 0) {
KeyScancode code;
// It looks like getting the first "event.characters" char is the

View File

@ -31,8 +31,10 @@ using namespace she;
NSRect rect = NSMakeRect(0, 0, width, height);
self = [self initWithContentRect:rect
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask)
styleMask:(NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable)
backing:NSBackingStoreBuffered
defer:NO];
if (!self)