Package libavg :: Module textarea :: Class TextArea

Class TextArea

source code

TextArea class is a libavg widget to create editable text fields

TextArea is an extended <words> node that reacts to user input (mouse/touch for focus, keyboard for text input). Can be set as a single line or span to multiple lines. It sits in a given container matching its dimensions, therefore the appropriate way to create it, is to set a <div> node with defined width/height attributes.

Instance Methods
 
__init__(self, parent, focusContext=None, disableMouseFocus=False, id='') source code
 
getID(self)
Returns the ID of the textarea (set on the constructor).
source code
 
clearText(self)
Clears the text
source code
 
setText(self, uString)
Set the text on the TextArea
source code
 
getText(self)
Get the text stored and displayed on the TextArea
source code
 
setStyle(self, font='Arial', fontsize=12, alignment='left', variant='Regular', color='000000', multiline=True, cursorWidth=None, border=0, blurOpacity=0.3, flashingCursor=False, cursorColor='000000', lineSpacing=0, letterSpacing=0)
Set TextArea's graphical appearance
source code
 
setMaxLength(self, maxlen)
Set character limit of the input
source code
 
clearFocus(self)
Compact form to blur the TextArea
source code
 
setFocus(self, hasFocus)
Force the focus (or blur) of this TextArea
source code
 
hasFocus(self)
Query the focus status for this TextArea
source code
 
onKeyDown(self, keycode)
Inject a keycode into TextArea flow
source code
Method Details

__init__(self, parent, focusContext=None, disableMouseFocus=False, id='')
(Constructor)

source code 
Parameters:
  • parent - a div node with defined dimensions
  • focusContext - FocusContext object which directs focus for TextArea elements
  • disableMouseFocus - boolean, prevents that mouse can set focus for this instance
  • id - optional handle to identify the object when dealing with events. ID uniqueness is not guaranteed

setText(self, uString)

source code 

Set the text on the TextArea

Parameters:
  • uString - an unicode string (or an utf-8 encoded string)

setStyle(self, font='Arial', fontsize=12, alignment='left', variant='Regular', color='000000', multiline=True, cursorWidth=None, border=0, blurOpacity=0.3, flashingCursor=False, cursorColor='000000', lineSpacing=0, letterSpacing=0)

source code 

Set TextArea's graphical appearance

Parameters:
  • font - font face
  • fontsize - font size in pixels
  • alignment - one among 'left', 'right', 'center'
  • variant - font variant (eg: 'bold')
  • color - RGB hex for text color
  • multiline - boolean, whether TextArea has to wrap (undefinitely) or stop at full width
  • cursorWidth - int, width of the cursor in pixels
  • border - amount of offsetting pixels that words node will have from image extents
  • blurOpacity - opacity that textarea gets when goes to blur state
  • flashingCursor - whether the cursor should flash or not
  • cursorColor - RGB hex for cursor color
  • lineSpacing - linespacing property of words node
  • letterSpacing - letterspacing property of words node

setMaxLength(self, maxlen)

source code 

Set character limit of the input

Parameters:
  • maxlen - max number of character allowed

setFocus(self, hasFocus)

source code 

Force the focus (or blur) of this TextArea

Parameters:
  • hasFocus - boolean

onKeyDown(self, keycode)

source code 

Inject a keycode into TextArea flow

Used mainly by FocusContext. It can be used directly, but the best option is always to use a FocusContext helper, which exposes convenience method for injection.

Parameters:
  • keycode (int (SDL reference)) - characted to insert