Example of DataGrid Form & Scroller
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Example of DataGrid Form & Scroller
Hi All:
I just wanted to share a sample stack that combines a DataGrid Form with a scroller control. I wanted more granular control on how to emulate a native iOS list which the field object did not provide.
I spent several days trying to figure this out and it seems that some of you are going through the same issues. Several of you pointed out to use touch messages instead of mouse messages, which turned out to be true, but the actual implementation of the touch messages took me a while to figure out.
So, for the benefit of all, attached is a simple DataGrid stack that you can build upon and use on your own projects.
Cheers
I just wanted to share a sample stack that combines a DataGrid Form with a scroller control. I wanted more granular control on how to emulate a native iOS list which the field object did not provide.
I spent several days trying to figure this out and it seems that some of you are going through the same issues. Several of you pointed out to use touch messages instead of mouse messages, which turned out to be true, but the actual implementation of the touch messages took me a while to figure out.
So, for the benefit of all, attached is a simple DataGrid stack that you can build upon and use on your own projects.
Cheers
- Attachments
-
- DataGrid Scroller-1.0.0.zip
- (9.72 KiB) Downloaded 486 times
-
- Posts: 80
- Joined: Fri Jul 09, 2010 6:28 pm
Re: Example of DataGrid Form & Scroller
Rick
Thanks for posting this. It's exactly what I need, however, I am seeing some strange effects ...
I have a DataGrid and and invisible field set up as a group in the middle of the ipad screen with some column headings above.
The scroll works, but it scrolls the original data out of the top of the data area without adding the lower data.
Also, very strangely, when I use the selected line to go to another card, and return to this one, the headings, (which are not in the group), are now down in the middle of the scrolled data area
I appreciate any ideas you may have
thanks
Steve
Thanks for posting this. It's exactly what I need, however, I am seeing some strange effects ...
I have a DataGrid and and invisible field set up as a group in the middle of the ipad screen with some column headings above.
The scroll works, but it scrolls the original data out of the top of the data area without adding the lower data.
Also, very strangely, when I use the selected line to go to another card, and return to this one, the headings, (which are not in the group), are now down in the middle of the scrolled data area
I appreciate any ideas you may have
thanks
Steve
Re: Example of DataGrid Form & Scroller
Hi Steve:
I ran into similar issues while developing my scrollers. things to whatch out for:
1) Make sure your DataGrid and DatGridScroller groups have the "Lock size and position" property checked.
2) Make sure that the dimensions & locations of the DataGrid and the DataGridScroller groups are exactly the same.
3) Make sure that the statement - iphoneControlSet sScrollerId, "contentRect", (0, 0, tWidth, tHeight) has 0,0 at the begining of the rect coordinates.
These were the main issues I found that gave me grief in my scroller implementation.
If you still have issues, fell free to post your stack and I will gladly take a look at it.
Cheers
I ran into similar issues while developing my scrollers. things to whatch out for:
1) Make sure your DataGrid and DatGridScroller groups have the "Lock size and position" property checked.
2) Make sure that the dimensions & locations of the DataGrid and the DataGridScroller groups are exactly the same.
3) Make sure that the statement - iphoneControlSet sScrollerId, "contentRect", (0, 0, tWidth, tHeight) has 0,0 at the begining of the rect coordinates.
These were the main issues I found that gave me grief in my scroller implementation.
If you still have issues, fell free to post your stack and I will gladly take a look at it.
Cheers
-
- Posts: 80
- Joined: Fri Jul 09, 2010 6:28 pm
Re: Example of DataGrid Form & Scroller
Brilliant
I was wrongly assuming that locking position was design only - Doh!
I just now need to get my movement or selection nailed, (if it's just one tap then I need to change the visibility of external controls on the card, otherwise scroll; and at the moment it's not seeing the tap - probably my bad interpretation of your code)
If I can't work it out, I'll give you a shout
Thanks for all the help, (and the great design)
Steve
PS Is there a document that lists the iPhoneControls, (like "scroller"), and their properties?
S.
I was wrongly assuming that locking position was design only - Doh!
I just now need to get my movement or selection nailed, (if it's just one tap then I need to change the visibility of external controls on the card, otherwise scroll; and at the moment it's not seeing the tap - probably my bad interpretation of your code)
If I can't work it out, I'll give you a shout
Thanks for all the help, (and the great design)
Steve
PS Is there a document that lists the iPhoneControls, (like "scroller"), and their properties?
S.
Re: Example of DataGrid Form & Scroller
Hi Steve:
I'm glad you are making progress.
The iOS Release Notes pdf that gets installed with Livecode is where you will find iOS specific documentation.
With regards to differentiating between a "Tap" or a "Scroll", look at the touchEnd script behind the "DataGrid 1" group. The if statement looks at how much scrolling you have done and if it is < 10 pixels it assumes it is a touch and processes the DataGrid selection. You can insert your specific code after the gdmouseDown command.
Hope this helps.
Cheers
I'm glad you are making progress.
The iOS Release Notes pdf that gets installed with Livecode is where you will find iOS specific documentation.
With regards to differentiating between a "Tap" or a "Scroll", look at the touchEnd script behind the "DataGrid 1" group. The if statement looks at how much scrolling you have done and if it is < 10 pixels it assumes it is a touch and processes the DataGrid selection. You can insert your specific code after the gdmouseDown command.
Hope this helps.
Cheers
-
- Posts: 80
- Joined: Fri Jul 09, 2010 6:28 pm
Re: Example of DataGrid Form & Scroller
Thanks Rick
I really should just read the entire release notes (I was just using it for reference).
Now I see all the useful things I should have been using.
Cheers
Steve
I really should just read the entire release notes (I was just using it for reference).
Now I see all the useful things I should have been using.
Cheers
Steve
Re: Example of DataGrid Form & Scroller
Thank you, thank you, thank you!
I had been poring over the example scroller and the rather lacking -- or scattered, perhaps -- documentation given by livecode and trying to apply it to nearly no avail. Having your example as a comparison helped immensely. My scroller is not quite perfect (is it ever?), but it's at least functional, and I still have some hair left on my head.
I feel like I need an "I'm not worthy!" smiley.
I had been poring over the example scroller and the rather lacking -- or scattered, perhaps -- documentation given by livecode and trying to apply it to nearly no avail. Having your example as a comparison helped immensely. My scroller is not quite perfect (is it ever?), but it's at least functional, and I still have some hair left on my head.

I feel like I need an "I'm not worthy!" smiley.
Re: Example of DataGrid Form & Scroller
Awesome example, Rick, thanks. However while your example stack compiles fine, when I paste your card into my stack and compile (having only changed line one of your opencard script - see below),I can't see any text in the scrolling field at all
on opencard
#Setup the Scroller ContectRect
put "600" into tHeight
-- I found I needed to put a value into tHeight otherwise the field didn't display at all.
-- It previously read "put (the dgFormattedHeight of group "DataGrid 1" of me) into tHeight"
put the width of group "DataGridScroll" into tWidth
iphoneControlSet sScrollerId, "contentRect", (0, 0, tWidth, tHeight)
set the height of group "DataGrid 1" to tHeight
set the top of group "DataGrid 1" to the top of grp "DataGridScroll"
end opencard

on opencard
#Setup the Scroller ContectRect
put "600" into tHeight
-- I found I needed to put a value into tHeight otherwise the field didn't display at all.
-- It previously read "put (the dgFormattedHeight of group "DataGrid 1" of me) into tHeight"
put the width of group "DataGridScroll" into tWidth
iphoneControlSet sScrollerId, "contentRect", (0, 0, tWidth, tHeight)
set the height of group "DataGrid 1" to tHeight
set the top of group "DataGrid 1" to the top of grp "DataGridScroll"
end opencard
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Example of DataGrid Form & Scroller
Rick, I solved my problem (above) by just moving all my cards to your stack - it all works fine now, and I've even figured out a bit about how it works
I have a question, however - how do I use this for a non-list scrolling field? What bits need to change? I just need a longish field (about 5 screenfuls of text in a small font size).
Cheers
Gerry

I have a question, however - how do I use this for a non-list scrolling field? What bits need to change? I just need a longish field (about 5 screenfuls of text in a small font size).
Cheers
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Example of DataGrid Form & Scroller
Hi Gerry:
For a non-list scrolling field you can use a regular text field instead of a datagrid. That should do it.
Cheers
For a non-list scrolling field you can use a regular text field instead of a datagrid. That should do it.
Cheers