Projects

Ticket #84 (closed defect: invalid)

Opened 4 years ago

Last modified 4 years ago

NSColor method dispatching problems

Reported by: psychs@… Owned by: lsansonetti@…
Priority: major Milestone:
Component: MacRuby Keywords:
Cc:

Description

framework 'Cocoa'

# it doesn't work
c = NSColor.colorWithCalibratedRed_green_blue_alpha(1.0, 1.0, 1.0, 1.0)

# it works
c = NSColor.colorWithCalibratedRed(1.0, green:1.0, blue:1.0, alpha:1.0)

# it doesn't work
c.blendedColorWithFraction_ofColor(0.5, NSColor.greenColor)

# it works
c.blendedColorWithFraction(0.5, ofColor:NSColor.greenColor)
test.rb:4:in `<main>': undefined method `colorWithCalibratedRed_green_blue_alpha' for NSColor:Class (NoMethodError)
test.rb:10:in `<main>': undefined method `blendedColorWithFraction_ofColor' for #<NSCachedRGBColor:0x14b6070> (NoMethodError)

Change History

Changed 4 years ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to invalid

This looks like an expected behavior. colorWithCalibratedRed_green_blue_alpha(a, b, c, d) is RubyCocoa-like syntax, which is not supported in MacRuby. It has to be rewritten like colorWithCalibratedRed(a, green:b, blue:c, alpha:d).

Corresponding Objective-C method is:

+ (NSColor *)colorWithCalibratedRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

What do you think?

Changed 4 years ago by eloy.de.enige@…

With the RubyCocoa layer:

% macirb -rosx/cocoa
irb(main):001:0> c = NSColor.colorWithCalibratedRed_green_blue_alpha(1.0, 1.0, 1.0, 1.0)
=> #<NSCachedRGBColor:0x1b148f0>
irb(main):002:0> c.blendedColorWithFraction_ofColor(0.5, NSColor.greenColor)
=> #<NSCalibratedRGBColor:0x1b36d10>

Changed 4 years ago by psychs@…

I think it should be treated in RubyCocoa compatibility layer. The layer is cool. Thanks.

Changed 4 years ago by lsansonetti@…

Works well :)

But Satoshi-san here is porting LimeChat to MacRuby, so he definitely wants to rewrite the syntax.

Note: See TracTickets for help on using tickets.