Package libavg :: Module textarea

Module textarea

source code


Single/Multi-Line editable text field widget for libavg

textarea module provides two classes:

1. TextArea
    This is the implementation of the widget. Every instantiated TextArea
    represents an editable text field, which can be set up with several styles
    and behaviors.
    
2. FocusContext
    This helps to easily route the events that comes from keyboards to an
    appropriate TextArea instance, cycling focuses and dispatching events on
    the selected field.

Classes
  FocusContext
This class helps to group TextArea elements
  TextArea
TextArea class is a libavg widget to create editable text fields
Functions
 
init(g_avg, catchKeyboard=True, repeatDelay=0.2, charDelay=0.1)
Initialization routine for the module
source code
 
setActiveFocusContext(focusContext)
Tell the module what FocusContext is presently active
source code
 
setActivityCallback(pyfunc)
Set a callback that is called at every keyboard's keypress
source code
Variables
  g_Player = None
  g_FocusContext = None
  g_LastKeyEvent = None
  g_activityCallback = None
  g_LastKeyRepeated = 0
  g_RepeatDelay = 0.2
  g_CharDelay = 0.1
  KEYCODE_TAB = 9
  KEYCODE_LINEFEED = 13
  KEYCODE_SHTAB = 25
  KEYCODE_FORMFEED = 12
  KEYCODE_CRS_UP = 63232
  KEYCODE_CRS_DOWN = 63233
  KEYCODE_CRS_LEFT = 63234
  KEYCODE_CRS_RIGHT = 63235
  KEYCODES_BACKSPACE = (8, 127)
  KEYCODES_DEL = 63272
  CURSOR_PADDING_PCT = 15
  CURSOR_WIDTH_PCT = 4
  CURSOR_SPACING_PCT = 4
  CURSOR_FLASHING_DELAY = 1000
  CURSOR_FLASH_AFTER_INACTIVITY = 200
  DEFAULT_BLUR_OPACITY = 0.3
Function Details

init(g_avg, catchKeyboard=True, repeatDelay=0.2, charDelay=0.1)

source code 

Initialization routine for the module

This method should be called immediately after avg file load (Player.loadFile())

Parameters:
  • g_avg - avg package
  • catchKeyboard - boolean, if true events from keyboard are catched
  • repeatDelay - wait time (seconds) before starting to repeat a key which is held down
  • charDelay - delay among character repetition (of an steadily pressed key)

setActiveFocusContext(focusContext)

source code 

Tell the module what FocusContext is presently active

Only one FocusContext at once can be set 'active' and therefore prepared to receive the flow of user events from keyboard.

Parameters:
  • focusContext - set the active focusContext. If initialization has been made with 'catchKeyboard' == True, the new active focusContext will receive the flow of events from keyboard.

setActivityCallback(pyfunc)

source code 

Set a callback that is called at every keyboard's keypress

If a callback of user interaction is needed (eg: resetting idle timeout) just pass a function to this method, which is going to be called at each user intervention (keydown, keyup). Active focusContext will be passed as argument