I am struggling getting to grips with declares and handlers to reach into UIKit events. I am trying to subclass an iOSTextField to add the ability to respond to the DidEndEditing and ShouldEndEditing events.
What I have done so far is
add two events to my iOSTextField
I have then added two methods
Sub RecDidEndEditing RaiseEvent DidEndEditing End Sub Function RecShouldEndEditing as Boolean return not RaiseEvent RecShouldEndEditing End Function
and finally have added a method which I intend to call in the open event of the iOSTextField
Sub AttachHandlers Declare sub DidEndEditing Lib "UIKit" Selector "textFieldDidEndEditing" (callback as Ptr) AddHandler DidEndEditing, address of RecDidEndEditing Declare sub ShouldEndEditing Lib "UIKit" Selector "textFieldShouldEndEditing" (callback as Ptr) as boolean AddHandler ShouldEndEditing, address of RecDidEndEditing End Sub
I have two issues.
1 - I am pretty sure the callback as Ptr is wrong. I think this should be a pointer to my iOSTextField, but have become lost as to how I do that.
2 - When I compile I get two errors on each line.
a - Type mismatch error. Expected delegate Delegate(myClass), but got Delegate( )
b - This method requires fewer parameters than were passed
AddHandler DidEndEditing, addressof RecDidEndEditing
and likewise for the second handler.
Any assistance would be gratefully received.