This simple module let's you create a text field which grows or shinks depending on the the content the user types, like iMessage, WhatsApp, etc.
TiGrowingTextField uses a third party library created by HansPinckaers: https://github.com/HansPinckaers/GrowingTextView/
And it's open sourced: https://github.com/iamyellow/TiGrowingTextField
Require the module and call and create the view:
var textField = require('net.iamyellow.tigrowingtextfield').createView({
// layout stuff -it works as any other view-
height: 40, // 40 is the minimum height, the view height won't be < 40
left: 10, right: 10,
// growing / shrink
minNumberOfLines: 1, // default = 1
maxNumberOfLines: 10, // default = 3,
showKeyboardImmediately: true,
// background stuff
backgroundImage: 'images/MessageEntryInputField.png',
backgroundLeftCap: 12,
backgroundTopCap: 20,
value: 'hellow',
// text stuff, works as Ti.UI.TextField
autocorrect: false, // disables / enables autocorrection
textAlign: 'left',
font: {
fontFamily: 'Georgia',
fontSize: 12
},
color: '#333333'
});
I guess properties names are self explanatory, except showKeyboardImmediately... well, sometimes I need the keyboard appears immediately as window is opened. Setting this to true makes it possible.
The field gains the focus.
The field loses the focus.
When it gains the focus.
When it loses the focus.
When the content changes. The event has properties:
-
value the content itself, the text field value.
-
height the current height.
https://gist.github.com/3123639
jordi domenech [email protected] http://iamyellow.net @iamyellow2
Copyright 2012 jordi domenech [email protected] Apache License, Version 2.0