Dim rect As NSRect

Hi everyone,

I’m fairly new to Xojo coming from a Python background

I’ve been reading this forum to learn how to call various classes in Cocoa and many use NSRect and other NS types. However, Xojo doesn’t seem to recognize these types when I use them. Many threads show these structures being dimensioned, in preparation to their use but I just get errors “Can’t find a type with this name”.

e.g.
Dim size As NSSize // NSSize gives a "Cannot find type with this name)
Dim rect As NSRect // NSRect gives a "Cannot find type with this name)
Declare Sub setTextContainerInset Lib “AppKit” Selector “setTextContainerInset:” (NSTextView As Ptr, inset As NSSize) // NSSize gives a "Cannot find type with this name)

Do I need to set up Xojo to recognize them first somehow or am I in need of a plugin?

Thanks for any insight you can offer.

you must define those yourself

Structure NSRect
  Origin as NSPoint
  Size_ as NSSize
End Structure with

Structure NSPoint
  x as CGFloat
  y as CGFloat
End Structure

Structure NSSize
  width as CGFloat
  height as CGFloat
End Structure

[quote=338830:@Dave S]you must define those yourself

[code]
Structure NSPoint
x as CGFloat
y as CGFloat
End Structure

Structure NSSize
width as CGFloat
height as CGFloat
End Structure

Structure NSRect
Origin as NSPoint
Size_ as NSSize
End Structure
[/code][/quote]

Thanks for helping Dave,
I tried this (in the order shown) but I get a syntax errors… seems Xojo doesn’t understand the Structure keyword. Autocomplete only shows StructureInfo also.

I’m using 2015 Release 2.1 on my Mac - could it be that it’s too old?

John… have you read the LangRef or accompanying documents?
You do not write a Structure in code… you define them with the structure wizard,

MENU -> INSERT -> STRUCTURE

Structures in Xojo have been around since before it was called Xojo…

Excellent! Thank you. This helps me understand the IDE better. Very much appreciated, Dave.