Revision: 22834
          http://sourceforge.net/p/bibdesk/svn/22834
Author:   hofman
Date:     2018-10-14 15:20:59 +0000 (Sun, 14 Oct 2018)
Log Message:
-----------
Allow named RGBA color specifiers

Modified Paths:
--------------
    trunk/bibdesk/NSColor_BDSKExtensions.m

Modified: trunk/bibdesk/NSColor_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.m      2018-10-14 15:01:28 UTC (rev 
22833)
+++ trunk/bibdesk/NSColor_BDSKExtensions.m      2018-10-14 15:20:59 UTC (rev 
22834)
@@ -170,9 +170,10 @@
 }
 
 + (id)scriptingRgbaColorWithDescriptor:(NSAppleEventDescriptor *)descriptor {
-    if ([descriptor numberOfItems] > 0) {
-        CGFloat red, green, blue, alpha;
-        red = green = blue = (CGFloat)[[descriptor descriptorAtIndex:1] 
int32Value] / 65535.0f;
+    if ([descriptor descriptorType] == typeAEList) {
+        CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
+        if ([descriptor numberOfItems] > 0)
+            red = green = blue = (CGFloat)[[descriptor descriptorAtIndex:1] 
int32Value] / 65535.0f;
         if ([descriptor numberOfItems] > 2) {
             green = (CGFloat)[[descriptor descriptorAtIndex:2] int32Value] / 
65535.0f;
             blue = (CGFloat)[[descriptor descriptorAtIndex:3] int32Value] / 
65535.0f;
@@ -185,8 +186,12 @@
             alpha= 1.0;
         return [NSColor colorWithCalibratedRed:red green:green blue:blue 
alpha:alpha];
     } else {
+        NSString *string = nil;
+        if ([descriptor descriptorType] == typeObjectSpecifier)
+            string = [[descriptor descriptorForKeyword:keyAEKeyData] 
stringValue];
+        else
+            string = [descriptor stringValue];
         // Cocoa Scripting defines coercions from string to color for some 
standard color names
-        NSString *string = [descriptor stringValue];
         NSColor *color = string ? [[NSScriptCoercionHandler 
sharedCoercionHandler] coerceValue:string toClass:[NSColor class]] : nil;
         // We should check the return value, because NSScriptCoercionHandler 
returns the input when it fails rather than nil, stupid
         return [color isKindOfClass:[NSColor class]] ? color : nil;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to