Closed rcarmo closed 3 years ago
Rectangle is NSRect (https://developer.apple.com/documentation/foundation/nsrect) under the hood. It’s a struct and not an object, so that’s the reason you get the error. I’m surprised nobody else has noticed this from documentation before. 😄 I’ll fix that.
Ah, ok. So I can't override it and do nice things like I do for Window
and Screen
. Hmmm.
@rcarmo You can of course pass it to functions, in a more functional approach.
const pad = (rect) => ({
...rect,
x: rect.x + PADDING,
});
Yeah, I wanted to make it smarter. Am now using something called a Frame
, which can .displace
, .pad
and .snap
, so I can do neat stuff like foo.snap(screen, WEST).pad()
I’ve clarified the documentation in this regard.
So I'm trying to extend Rectangle:
... and I get
ReferenceError: Can't find variable: Rectangle (Line:Column)
Since I can hack
Screen
, shouldn't I be able to do the same forRectangle
, so that I can take aWindow.frame
and manipulate it directly like this?