Previously, unless you were using a sheet alert, there was no way to set a custom dismissal handler for an alert. In Cocoa alerts are synchronous, in Cappuccino they are asynchronous, which meant that a single dismissal handler had to handle all possible non-sheet alerts.
This commit adds several methods which add two ways to specify a custom dismissal handler: via delegate/selector, and via a block (function). The new methods are:
setDidEndSelector:
runModalWithDidEndBlock:
beginSheetModalForWindow:didEndBlock:
Note that didEnd blocks are transient and take precedence over didEnd selectors.
The CPAlertTest demo was updated to fix some bugs and added the ability to run the tests using blocks.
In Objective-C, both `[@34 compare:nil]` and `[@34 compare:[CPNull null]]` throw invalid argument exceptions.
This fix makes the same true in Objective-J.
Refs #1959.
Previously, certain situations could easily lead to an infinite loop in - CPView nextValidKeyView. For instance, opening a sheet view with no responder returning YES for canBecomeKeyView would freeze Cappuccino.
This was caused by the cycle detection in nextValidKeyView not being able to pick up on cycles where the nextKeyView of the original receiver did not participate. Since content views often have a next key view inside of them, and the views inside rarely have a next key view back "up" to the content view, the content view would never be seen again even if there was a cycle.
This fix detects cycles at any level by remembering all previous visited responders.
This change brings nearly all copy and paste related into a single, self-contained class. This new class is still somewhat coupled to CPPlatformWindow+DOM.j in the sense that it's highly specific and meant to be called in a very specialised way. Despite this, it's still a significant decoupling and the new code is more readable and easier to follow.
Image copy and paste to and from the system clipboard is not available in Cappuccino today. However, the image in the collection view can be used to test internal Cappuccino copy and paste (using Edit > Copy, Edit > Paste from the Cappuccino menu).
This test makes it easy to test copy and paste both inside a Cappuccino app, and externally to and from other Cappuccino instances in other browser, or other applications, when using a text field or a collection view as the source/destination.
Without this fix, certain JS contents could cause `- CPDictionary description` and `- CPArray description` to crash.
This change limits how deeply the description code will recurse before returning a default "…" description.
Without this fix, code like `[@{ "a": window } description]` would crash with a "Maximum call stack size exceeded" exception.
Now`CPDescriptionOfObject()` function simply describes the window object as `window` rather than trying to serialise it into a huge description string.
Without this fix, CGRectFromString would call CGSizeFromString with a value like "{1, 2}}" (not the extra trailing "}"). Although CGSizeFromString didn't complain, it wasn't correct either.
The program below crashed on the last line with a 'null is not an object' error message. Also added a test case.
@implementation MyObject {
- (int):(int)a {
return a;
}
@end
var a = [[MyObject alloc] init];
var b = [a:3];
- CPImageInBundle() can't be used from a ThemeDescriptor. Replaced with PatternImage().
- DRY! Put clock image sizes in variables so they can be maintained in one place.
- When displayed from the theme showcase, the hand images in HandLayer -setImage: were still _CPCibCustomResources, not sure why. This condition is now explicitly handled by converting to the referenced image.
- Fixed a bug in _CPDatePickerClock -setEnabled where the sublayers would not update unless the event loop was pumped.
- Check for unchanged value in setters.
- Various code optimizations.
- Removed unnecessary method comments.
- Fixed typo in demo app.
Previously when creating a CGPath with an arc, the path was wrong. It added a line when it wasn't necessary and when it was necessary it added a line to a wrong point.
Now CGPath works like in cocoa (If the specified path already contains a subpath, Quartz implicitly adds a line connecting the subpath’s current point to the beginning of the arc. If the path is empty, Quartz creates a new subpath with a starting point set to the starting point of the arc.)
Test app in Tests/Manual/CGPath/AppController.j
Canvas supports CGContextDrawRadialGradient as in cocoa. The CGGradientDrawingOptions is not actually supported.
Test app in Tests/Manual/CGCanvasContext