How to get a text field to resize properly...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

How to get a text field to resize properly...

Post by rumplestiltskin » Fri Jun 10, 2011 2:50 am

...when the iOS device is rotated?

I've been reading that the geometry manager doesn't work in iOS yet. Any workarounds?

Also: What sort of field should I drop into a stack so that it would provide iOS-native appearance when scrolling? I imagine this would have to be a locked field so touching it (during runtime on the iOS device) wouldn't bring up the keyboard.

Any advice is welcome.

Thanks,
Barry

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get a text field to resize properly...

Post by Klaus » Fri Jun 10, 2011 12:22 pm

Hi Barry,
rumplestiltskin wrote:...when the iOS device is rotated?
I've been reading that the geometry manager doesn't work in iOS yet. Any workarounds?
since the current card will receive a "resizestack" message in that case, you can (need to!)write your own resize handlers.
rumplestiltskin wrote:Also: What sort of field should I drop into a stack so that it would provide iOS-native appearance when scrolling?
I imagine this would have to be a locked field so touching it (during runtime on the iOS device) wouldn't bring up the keyboard.
Check the "iOS Rlease Notes" for "Scroller control – UIScrollView".
That is what you are looking for.

Sorry, did not work with this yet, so I cannot gibe any hints on how to do this.
But there is an example stack, select Menu: Help: Example Stacks and resources

This will open the appropriate folder and in its subfolder "Mobile Examples" you will find a stack "Scroller Example.livecode".
Open it and check the scripts.
rumplestiltskin wrote:I imagine this would have to be a locked field so touching it (during runtime on the iOS device) wouldn't bring up the keyboard.
Yes. :)


Best

Klaus

rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Re: UIScrollView

Post by rumplestiltskin » Fri Jun 10, 2011 7:44 pm

I just read the notes on UIScrollView. There's something missing:

1. How does one actually create such a control in LiveCode? It's not listed in the Objects>New Control menu.

2. Does it get grouped to a scrolling textfield that has had its vertical scrollbar disabled in the Property Inspector?

Thanks,
Barry

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get a text field to resize properly...

Post by Klaus » Sat Jun 11, 2011 1:14 am

Hi Barry,

1. only via script!
2. yes.

Check the "scroller" example I mentioned in my last posting.


Best

Klaus

rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Re: How to get a text field to resize properly...

Post by rumplestiltskin » Sat Jun 11, 2011 2:17 am

Klaus,

Thanks for your help. I've been working with the MobGUI pallete that "splash21" posted on his website:
http://www.splash21.com/MobGUI/

I've actually managed to get a scrolling text field working but it looks like I have to programmatically set the height of the field based upon the height of the total amount of text I put into that field during runtime; otherwise, a too-short field cuts off the text and a too-long field scrolls past the end of the text to the physical end of the field. I seem to recall there's a way of determining the total height by querying a couple of properties.

Barry

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get a text field to resize properly...

Post by Klaus » Sat Jun 11, 2011 11:12 am

Hi Barry,

you need to set the height of the field to its "formattedheight" :)
Check "formattedXYZ" in the dicitonary.

Best

Klaus

rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Re: How to get a text field to resize properly...

Post by rumplestiltskin » Sat Jun 11, 2011 3:28 pm

Perfect! Just two or three lines of code and I can alter the height as req'd.

Thanks very much for your guidance. I'll have to post an example later today when I get a chance to do some coding.

Barry

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get a text field to resize properly...

Post by Klaus » Sat Jun 11, 2011 7:09 pm

Hi Barry,

my pleasure :)


Best from germany

Klaus

rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Re: How to get a text field to resize properly...

Post by rumplestiltskin » Sun Jun 12, 2011 3:43 pm

Well, I've got the text field to re-size itself automatically depending on the amount of text (using the formattedHeight property); however, I seem to be having a bit of difficulty with the "orientationChanged" message. I've got an "on orientationChanged" handler in the card script that is supposed to change the width of the scrolling field to match the width of the scroller (the scroller width changes automatically - I'm using MobGUI):

Code: Select all

on orientationChanged
   put the rect of group "Scroller-1006" into theCorners
   set the rect of field "field 1" to (item 1 of theCorners,item 2 of theCorners, item 3 of theCorners, the formattedHeight of field "field 1")
end orientationChanged
Perhaps I'm misunderstanding the nature of the message (or maybe MobGUI is intercepting it somewhere).

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get a text field to resize properly...

Post by Klaus » Sun Jun 12, 2011 4:03 pm

Hi rumplestiltskin,

did you read this carefully?

From the "iOS Release Notes":
-------------------------------------------------------
Orientation changed notification
An application will receive an orientationChanged message if the device detects a change in its position relative to the ground,
and you can use the iphoneDeviceOrientation() function to find out the current orientation.
This message is sent to the current card of the default stack.

The orientationChanged message is sent before any automatic interface rotation takes place thus changes to the orientation
lock state and allowed set can be made at this point and still have an effect.

If you wish to perform an action after the interface has been rotated, then either do so on receipt of resizeStack,
or by using a send in 0 millisecs message.

-------------------------------------------------------

Looks like you re-size your objects just too early?
Try to change "orientationchanged" with "resizestack", maybe that will be enough.


Best

Klaus

Post Reply