I have a view (name View1) with a iOSScrollableArea. This iOSScrollableArea has a Behaviour to a iOSContainerControl. This iOSContainerControl has a Canvas with a PointerDown event that should push a new view (name View2) in View1. How can I do this?
There are many ways to do this, my preferred is to use a delegate.
When creating the Containercontrol give it a WeakAdressOf reference to the function in View1 that will open View2.
ContainerControl1.PointerDownCallback = WeakAdressOf View1.OpenView2
Then in PointerDown event :
try if PointerDownCallback <> nil then PointerDownCallback.invoke End if catch End Try
I don’t recommend using the PointerDown event of a Canvas that is in a Containercontrol within a scrollable area.
The user might place the finger on the canvas in order to scroll, not to point down. Also, users don’t expect an action to happen on PointerDown, but on PointerUp if and only if the finger is still in the control bounds.
The best way to do this is to use a TapGestureRecognizer available in iOSKit.
How can I create a delegate “WeakAdressOf reference” ?
In the Container create a new delegate, name it “SimpleDelegate”. Don’t add any parameters.
In the Container create a new public property named “PointerCallback As SimpleDelegate”
In the View create a new method named “OpenView2” for example.
In View1 when you are setting up the ScrollableArea with the Container add the following line:
ContainerControl1.PointerCallback = WeakAddressOf me.OpenView2
If you use the Xojo layout editor to set the container in the Scrollable area, the code should be:
ContainerControl1(ScrollableArea1.Contents).PointerCallback = WeakAddressOf me.OpenView2
EDIT: WeakAddressOf takes two D’s
I got this error:
View1.Open, line 3
This item does not exist
cc.PointerDownCallback = WeakAdressOf me.OpenView2
WeakAddressOf takes two D’s
and it is cc.PointerCallback instead of PointerDownCallback
Thanks. Now it works fine.