From 6e7e3ef35e508077077f13d84330579f36034d25 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Thu, 8 Oct 2009 19:28:45 -0700 Subject: [PATCH 1/6] Updates to TextField. Closes #219. Closes #283. Closes #232. --- AppKit/CPTextField.j | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index b4dc02792..2f6135dc2 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -243,7 +243,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); { CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; - CPTextFieldKeyPressFunction(anEvent); + //CPTextFieldKeyPressFunction(anEvent); return true; } @@ -252,6 +252,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); { aDOMEvent = aDOMEvent || window.event; + CPTextFieldKeyUpFunction(); + if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode) { if (aDOMEvent.preventDefault) @@ -281,12 +283,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); CPTextFieldKeyUpFunction = function() { - [CPTextFieldInputOwner setStringValue:CPTextFieldDOMInputElement.value]; + [CPTextFieldInputOwner _setStringValue:CPTextFieldDOMInputElement.value]; if ([CPTextFieldInputOwner stringValue] !== CPTextFieldTextDidChangeValue) { - CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; [CPTextFieldInputOwner textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:CPTextFieldInputOwner userInfo:nil]]; + CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; } [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; @@ -551,8 +553,10 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); /* @ignore */ - (BOOL)becomeFirstResponder { +#if PLATFORM(DOM) if (CPTextFieldInputOwner && [CPTextFieldInputOwner window] !== [self window]) [[CPTextFieldInputOwner window] makeFirstResponder:nil]; +#endif [self setThemeState:CPThemeStateEditing]; @@ -590,7 +594,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); window.setTimeout(function() { - element.focus(); + element.value = [self stringValue]; + element.focus(); CPTextFieldInputOwner = self; }, 0.0); @@ -681,10 +686,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); /* @ignore */ +- (void)_setStringValue:(id)aValue +{ + [super setObjectValue:String(aValue)]; + [self _updatePlaceholderState]; +} + - (void)setObjectValue:(id)aValue { [super setObjectValue:aValue]; +#if PLATFORM(DOM) + if (CPTextFieldInputOwner === self) + [self _inputElement].value = aValue; +#endif + [self _updatePlaceholderState]; } From 69cdc2ccd044a3adc75b20447254465b5cc0df87 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Thu, 8 Oct 2009 21:41:35 -0700 Subject: [PATCH 2/6] Check for "system", fixes press. --- Objective-J/evaluate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objective-J/evaluate.js b/Objective-J/evaluate.js index 50a902d63..02e33aaf3 100644 --- a/Objective-J/evaluate.js +++ b/Objective-J/evaluate.js @@ -159,7 +159,7 @@ function fragment_evaluate_code(aFragment) { #if RHINO var functionText = "function(){"+GET_CODE(aFragment)+"/**/\n}"; - if (system.engine === "rhino") + if (typeof system !== "undefined" && system.engine === "rhino") compiled = Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, functionText, GET_FILE(aFragment).path, 0, null); else compiled = eval(functionText); From 5e951c1e5358ce103b90689e0abf128f25b2527e Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Thu, 8 Oct 2009 21:50:03 -0700 Subject: [PATCH 3/6] Fix for a break in key view loops from the previous text field change. --- AppKit/CPTextField.j | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 2f6135dc2..0303ee1bb 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -239,11 +239,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); return true; } - CPTextFieldKeyDownFunction = function(anEvent) + CPTextFieldKeyDownFunction = function(aDOMEvent) { CPTextFieldTextDidChangeValue = [CPTextFieldInputOwner stringValue]; - //CPTextFieldKeyPressFunction(anEvent); + aDOMEvent = aDOMEvent || window.event; + + if (aDOMEvent.keyCode == CPReturnKeyCode || aDOMEvent.keyCode == CPTabKeyCode) + CPTextFieldKeyPressFunction(aDOMEvent); return true; } @@ -276,7 +279,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); else [[owner window] selectPreviousKeyView:owner]; } - } + } [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; } From fc85ae16a5ddbefce64b76afbb0ce76143324ea4 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Thu, 8 Oct 2009 23:10:58 -0700 Subject: [PATCH 4/6] Fix for the keypress bug introduced in Safari 4. Closes #280. --- AppKit/CPCompatibility.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index b381cd359..2539b2ab1 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -114,7 +114,7 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1) majorVersion = parseInt(versionString.substring(0, versionDivision)), minorVersion = parseInt(versionString.substr(versionDivision + 1)); - if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion >= 525 && minorVersion > 14)) || USER_AGENT.indexOf("Chrome") !== CPNotFound) + if((USER_AGENT.indexOf("Safari") !== CPNotFound && (majorVersion > 525 || (majorVersion === 525 && minorVersion > 14))) || USER_AGENT.indexOf("Chrome") !== CPNotFound) PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport; } From bc6f168afac174fea8aef80c629310c3f43f242b Mon Sep 17 00:00:00 2001 From: Nicholas Small Date: Tue, 6 Oct 2009 21:01:07 -0400 Subject: [PATCH 5/6] Added some designated initializers to AppKit. --- AppKit/CPBox.j | 4 +++- AppKit/CPImage.j | 13 +++++++++---- AppKit/CPMenuItem.j | 5 +++++ AppKit/CPTabViewItem.j | 5 +++++ AppKit/CPTableColumn.j | 5 +++++ AppKit/CPToolbar.j | 5 +++++ AppKit/CPToolbarItem.j | 5 +++++ 7 files changed, 37 insertions(+), 5 deletions(-) diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index 2a0f45ff2..05500b550 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -58,7 +58,9 @@ CPGrooveBorder = 3; - (id)initWithFrame:(CPRect)frameRect { - if (self = [super initWithFrame:frameRect]) + self = [super initWithFrame:frameRect]; + + if (self) { _fillColor = [CPColor clearColor]; _borderColor = [CPColor blackColor]; diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index e42bf35b1..bd9e746fa 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -90,6 +90,11 @@ function CPImageInBundle(aFilename, aSize, aBundle) Image _image; } +- (id)init +{ + return [self initByReferencingFile:@"" size:CGSizeMake(-1, -1)]; +} + /*! Initializes the image, by associating it with a filename. The image denoted in \c aFilename is not actually loaded. It will @@ -98,7 +103,7 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aSize the image's size @return the initialized image */ -- (CPImage)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize +- (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize { self = [super init]; @@ -118,7 +123,7 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aSize the size of the image @return the initialized image. */ -- (CPImage)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize +- (id)initWithContentsOfFile:(CPString)aFilename size:(CGSize)aSize { self = [self initByReferencingFile:aFilename size:aSize]; @@ -134,9 +139,9 @@ function CPImageInBundle(aFilename, aSize, aBundle) @param aFilename the file name of the image @return the initialized image */ -- (CPImage)initWithContentsOfFile:(CPString)aFilename +- (id)initWithContentsOfFile:(CPString)aFilename { - self = [self initByReferencingFile:aFilename size: CGSizeMake(-1, -1)]; + self = [self initByReferencingFile:aFilename size:CGSizeMake(-1, -1)]; if (self) [self load]; diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index b738729ed..2a35aceb2 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -78,6 +78,11 @@ _CPMenuItemView _menuItemView; } +- (id)init +{ + return [self initWithTitle:@"" action:nil keyEquivalent:nil]; +} + /*! Initializes the menu item with a title, action, and keyboard equivalent. @param aTitle the menu item's title diff --git a/AppKit/CPTabViewItem.j b/AppKit/CPTabViewItem.j index 0ebc4a5e0..356f4f1af 100644 --- a/AppKit/CPTabViewItem.j +++ b/AppKit/CPTabViewItem.j @@ -60,6 +60,11 @@ CPPressedTab = 2; CPView _auxiliaryView; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + /*! Initializes the tab view item with the specified identifier. @return the initialized CPTabViewItem diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index aaf50090b..9653af630 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -62,6 +62,11 @@ CPTableColumnUserResizingMask = 2; CPString _headerToolTip; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + - (id)initWithIdentifier:(id)anIdentifier { self = [super init]; diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 6bcff4a60..8f019a2f8 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -128,6 +128,11 @@ var CPToolbarConfigurationsByIdentifier = nil; [toolbarsSharingIdentifier addObject:toolbar]; } +- (id)init +{ + return [self initWithIdentifier:@""]; +} + /*! Initializes the toolbar with the specified identifier. @param anIdentifier the identifier for the toolbar diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j index 64c4aea7c..7c1ac52bc 100644 --- a/AppKit/CPToolbarItem.j +++ b/AppKit/CPToolbarItem.j @@ -86,6 +86,11 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier"; int _visibilityPriority; } +- (id)init +{ + return [self initWithItemIdentifier:@""]; +} + // Creating a Toolbar Item /*! Initializes the toolbar item with a specified identifier. From e12513977712ebcdcb911a115586d0fca9ec6dae Mon Sep 17 00:00:00 2001 From: Jake MacMullin Date: Wed, 16 Sep 2009 15:56:43 +1000 Subject: [PATCH 6/6] Fixed a bug where the CPAlert was being displayed with black text on a black background if the styleMask was set to 'CPHUDBackgroundWindowMask' and something else. #220 --- AppKit/CPAlert.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index 6e41f149b..75b63ce9d 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -149,7 +149,7 @@ var CPAlertWarningImage, [_alertPanel setFloatingPanel:YES]; [_alertPanel center]; - [_messageLabel setTextColor:(styleMask == CPHUDBackgroundWindowMask) ? [CPColor whiteColor] : [CPColor blackColor]]; + [_messageLabel setTextColor:(styleMask & CPHUDBackgroundWindowMask) ? [CPColor whiteColor] : [CPColor blackColor]]; var count = [_buttons count]; for(var i=0; i < count; i++) @@ -157,7 +157,7 @@ var CPAlertWarningImage, var button = _buttons[i]; [button setFrameSize:CGSizeMake([button frame].size.width, (styleMask == CPHUDBackgroundWindowMask) ? 20.0 : 24.0)]; - [button setBezelStyle:(styleMask == CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle]; + [button setBezelStyle:(styleMask & CPHUDBackgroundWindowMask) ? CPHUDBezelStyle : CPRoundedBezelStyle]; [[_alertPanel contentView] addSubview:button]; }