Python3Script Xojo Plugin |

# Python3XojoClass.RegisterGetterSetter Method (console safe)

Registers Getter and or Setter to the class.

RegisterGetterSetter(
name as String,
getterPtr as Ptr,
setterPtr as Ptr)

#### Parameters

name
  Name of the property.
getterPtr
  Address of the getter handler or nil if there should be no getter.
setterPtr
  Address of the setter handler or nil if there should be no setter.

#### Remarks

You would normally class this in your register class handler.

xojoClass.RegisterGetterSetter("x", AddressOf GetX, AddressOf SetX)
Private Shared Function GetX(pySelf as Ptr, closure as Ptr) As Ptr
var data as MyXojoClass = MyXojoClass(Python3XojoClass.Data(pySelf))
return Python3Entity.FromInt64(data.x).GetPtr()
End Function
Private Shared Function SetX(pySelf as Ptr, value as Ptr, closure as Ptr) As Integer
var data as MyXojoClass = MyXojoClass(Python3XojoClass.Data(pySelf))
var r as Python3Entity = Python3Entity.FromPtr(value)
if not r.IsInteger then
Python3Script.SetError(Python3ErrorTypes.TypeError, "x can only be set to Integer type")
return -1
end if
data.x = r.Int64Value
return 0 // Success
End Function

#### See Also

Python3XojoClass Class