ScrollableView

Is there a way I can make my view scrollable?

Not built in yet.
@jim mckay was working on a solution when r3 was in Beta.
Don’t know how it’s going with that though :slight_smile:

Albin - I have not tried iOS yet.
Are you saying that we are limited to a single screen height’s worth of information???

[quote=150738:@Richard Summers]Albin - I have not tried iOS yet.
Are you saying that we are limited to a single screen height’s worth of information???[/quote]
Yepp, we are. Someone needs to figure out what declares to use to get this to work.
@jim mckay might chime in here :wink:

Try the EddiesElectronix iOS example and put the simulator in Landscape mode and you’ll see it :wink:

There is a workaround. It is not the most pretty but it works for now :

  • lay a long canvas on the surface of the view,
  • put controls on it and make sure constraints refer to the canvas so they be attached to it
  • use this Antonio Rinaldi posted in Beta to move Rectangle1 that is placed under the canva, but can be used for the canvas itself :

Antonio Rinaldi Dec 8 Beta Testers, Xojo Pro Europe (Italy)
Try this:

Sub PointerDown(pos As Xojo.Core.Point, eventInfo As iOSEventInfo) dim r as Rect=Rectangle1.frame if r.Contains(pos) then //this if you want to move the object only when you touch within it down=new Point(pos.X-r.Center.x,pos.y-r.Center.y) else down=nil System.DebugLog "OUT" end if Label1.text = "PointerDown !" End Sub

[code]Sub PointerDrag(pos As Xojo.Core.Point, eventInfo As iOSEventInfo)
if down=nil then Return

dim dx,dy as Single
dx=pos.X-down.x
dy=pos.y-down.y

Rectangle1.center=new Point(dx,dy)
End Sub
Sub PointerUp(pos As Xojo.Core.Point, eventInfo As iOSEventInfo)
down=nil
End Sub[/code]
You need these in a Module:

Function frame(extends c as iOSControl) As rect declare function frame_ lib "UIKIT" selector "frame"(o as Ptr) as cgrect dim r as cgrect=frame_(c.Handle) Return new rect(r.x,r.y,r.width,r.height) End Function

Sub center(extends c as iOSControl,assigns p as point) Declare sub setCenter lib "UIKIT" selector "setCenter:"(o as Ptr, pt as cgpoint) dim pt as cgpoint pt.x=p.X pt.y=p.y setCenter(c.Handle,pt) End Sub

structure CGPoint x as single y as single

structure CGRect x as single y as single width as single height as single

Here is the project I made with his help. I also added code in the PointerUp to synchronize the declare actions with AutoLayout constraints at the end of the move so the next rotation will not rest the move.

carre?.xojo_binary_project

This is only a workaround. During beta Jim had produced a working scrolling view, but the evolution of the product has broken it. I have no doubt that when he has time he will come back to it and dazzle us all :slight_smile:

Michel, looks great until Jim do the “dazzle”.
But I might not be getting it. Nothing happens when I try to “scroll” the view in the simulator and after a while it crashes on View1.Canvas1.PointerUp: RLeft.Offset = (pos.X-down.x) - RWidth.Offset/2

Great work though! :slight_smile:

[quote=150754:@Albin Kiland]Michel, looks great until Jim do the “dazzle”.
But I might not be getting it. Nothing happens when I try to “scroll” the view in the simulator and after a while it crashes on View1.Canvas1.PointerUp: RLeft.Offset = (pos.X-down.x) - RWidth.Offset/2

Great work though! :-)[/quote]

This just moves the rectangle. I am working on moving the canvas now.

OK. here is the result of a quick workaround based on Antonio’s declare to move controls. This moves the canvas, and in turn this moves the controls relative to it when one releases the pointer.

scroller.xojo_binary_project

Note that this is just a proof of concept, where controls actually move only when the finger is lifted, because the autolayout constraints are updated with the new position of the canvas.

To obtain a smooth scroll of all controls is not difficult but it requires moving them in the PointerDrag event, and I wanted to post the project right away. Use the Center method to move the controls, and update their constraints the same way I do it for the canvas. The trick is to know that the Center method is relative to the view, not the canvas.

Updating the constraints is necessary to prevent rotate from putting the view back in its default state.

I did not spend much time on this since I have the feeling it may become futile when Jim will have updated his scrollview declare. Moving a control with the finger will remain useful, though.

An iOSTable scrolls nicely. Like a listbox in desktop apps. There is just no built in way to scroll a whole view yet.

Yep. The initial iOS control set is somewhat limited. But at least we have an iOS target now…

I need the scrollable view as well…