diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp index bb32357d2a..3647390519 100644 --- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp +++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp @@ -846,7 +846,7 @@ void GraphicsNode::flattenPaths() { if (_curPath && _curPath->points.size() <= 1) { _nPath --; - _curPath = _paths[_nPath - 1]; + _curPath = _nPath > 0 ? _paths[_nPath - 1] : nullptr; } for (int i = _pathOffset; i < _nPath; i++) { diff --git a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h index 04f6bb6c92..032cf70b85 100644 --- a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h +++ b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h @@ -26,7 +26,7 @@ #import #include "ui/UIEditBox/Mac/CCUITextInput.h" -@interface CCUIPasswordTextField : NSSecureTextField +@interface CCUIPasswordTextField : NSTextField { NSMutableDictionary* _placeholderAttributes; } diff --git a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m index 4885a8f7ea..8d04eb3d73 100644 --- a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m +++ b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m @@ -1,19 +1,19 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2016 zilongshanren - + http://www.cocos2d-x.org - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -26,6 +26,78 @@ #import "ui/UIEditBox/Mac/CCUIPasswordTextField.h" #include "ui/UIEditBox/Mac/CCUITextFieldFormatter.h" +@interface RSVerticallyCenteredSecureTextFieldCell : NSSecureTextFieldCell +{ + BOOL mIsEditingOrSelecting; +} + +@end + +@implementation RSVerticallyCenteredSecureTextFieldCell + +- (NSRect)drawingRectForBounds:(NSRect)theRect +{ + // Get the parent's idea of where we should draw + NSRect newRect = [super drawingRectForBounds:theRect]; + + // When the text field is being + // edited or selected, we have to turn off the magic because it screws up + // the configuration of the field editor. We sneak around this by + // intercepting selectWithFrame and editWithFrame and sneaking a + // reduced, centered rect in at the last minute. + if (mIsEditingOrSelecting == NO) + { + // Get our ideal size for current text + NSSize textSize = [self cellSizeForBounds:theRect]; + + // Center that in the proposed rect + float heightDelta = newRect.size.height - textSize.height; + if (heightDelta > 0) + { + newRect.size.height -= heightDelta; + newRect.origin.y += (heightDelta / 2); + } + } + + return newRect; +} + +- (void)selectWithFrame:(NSRect)aRect + inView:(NSView *)controlView + editor:(NSText *)textObj + delegate:(id)anObject + start:(long)selStart + length:(long)selLength +{ + aRect = [self drawingRectForBounds:aRect]; + mIsEditingOrSelecting = YES; + [super selectWithFrame:aRect + inView:controlView + editor:textObj + delegate:anObject + start:selStart + length:selLength]; + mIsEditingOrSelecting = NO; +} + +- (void)editWithFrame:(NSRect)aRect + inView:(NSView *)controlView + editor:(NSText *)textObj + delegate:(id)anObject + event:(NSEvent *)theEvent +{ + aRect = [self drawingRectForBounds:aRect]; + mIsEditingOrSelecting = YES; + [super editWithFrame:aRect + inView:controlView + editor:textObj + delegate:anObject + event:theEvent]; + mIsEditingOrSelecting = NO; +} + +@end + @interface CCUIPasswordTextField() @property (nonatomic, retain) NSMutableDictionary *placeholderAttributes; @@ -45,15 +117,22 @@ font, NSFontAttributeName, [NSColor grayColor], NSForegroundColorAttributeName, nil]; + [self setLineBreakMode:NSLineBreakByTruncatingTail]; + } - + return self; } ++(void)load +{ + [self setCellClass:[RSVerticallyCenteredSecureTextFieldCell class]]; +} + - (void)dealloc { self.placeholderAttributes = nil; - + [super dealloc]; } @@ -81,9 +160,9 @@ { NSAttributedString *as = [[NSAttributedString alloc] initWithString:text attributes:self.placeholderAttributes]; - + [[self cell] setPlaceholderAttributedString:as]; - + [as release]; } diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index aa22263424..ada75113cd 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -32,5 +32,10 @@ MainMenu NSPrincipalClass NSApplication + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index aa22263424..ada75113cd 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -32,5 +32,10 @@ MainMenu NSPrincipalClass NSApplication + NSAppTransportSecurity + + NSAllowsArbitraryLoads + +