[Rubycocoa-devel 954] suggestion: dup method of NSPoint, NSSize, NSPoint and NSRange

Back to archive index

Satoshi Nakagawa snaka****@infot*****
Tue Jun 5 23:30:56 JST 2007


Hi.

Currently when I wrote some drawing code, I often want to dup NSRect, NSSize and NSPoint.

For example,

  rect = NSRect.new(frame.origin, frame.size)
  rect.origin.x += 10
  'str'.drawInRect(rect)

I want to write more smartly like,

  rect = frame.dup

But it causes an error: RuntimeError: Given structure 0x1510a44 has null data.

So I wrote an utility code:

----
module OSX
  class NSPoint
    def dup; NSPoint.new(self.x, self.y); end
  end
 
  class NSSize
    def dup; NSSize.new(self.width, self.height); end
  end
 
  class NSRect
    def dup; NSRect.new(self.origin, self.size); end
  end
 
  class NSRange
    def dup; NSRange.new(self.location, self.length); end
  end
end
----

It's convenient for me.
I think it's convenient for the other people.

Could you add the code to RubyCocoa?

--
Satoshi Nakagawa




More information about the Rubycocoa-devel mailing list
Back to archive index