Text Area Margin

Hi everyone,

I have the following code which worked a few years back when I last used Xojo.
It allowed me to set a margin in a text area, basically giving it some padding.

Unfortunately it now no longer works using the latest Xojo on an intel macOS 11 system.

Does anyone know if it is the declares which need updating?

// CREATE A STRUCTURE IN THE WINDOW CALLED "NSSize".
// CREATE 2 ENTRIES IN THE STRUCTURE:   "width As Single", and "height As Single"


// INSERT INTO THE TEXT AREA'S OPEN EVENT

Dim margin As NSSize
margin.width = 15
margin.height = 15
  
Declare Function documentView Lib "Cocoa" Selector "documentView" (obj_id As Integer) As Ptr
Dim ref As Ptr = documentView(Me.Handle)
  
Declare Sub setTextContainerInset Lib "Cocoa" Selector "setTextContainerInset:" (obj_id As Ptr, value As NSSize)
setTextContainerInset(ref, margin)

Thank you all in advance.

Change your NSSize to use double’s instead of singles, OR CGFloat’s

2 Likes

Thanks Graham, I will try that tonight.
Much appreciated!