Package muntjac :: Package ui :: Module component :: Class IFocusable
[hide private]
[frames] | no frames]

Class IFocusable

source code

                        object --+            
                                 |            
               util.IEventListener --+        
                                     |        
         terminal.paintable.IPaintable --+    
                                         |    
                            object --+   |    
                                     |   |    
terminal.variable_owner.IVariableOwner --+    
                                         |    
                            object --+   |    
                                     |   |    
           terminal.sizeable.ISizeable --+    
                                         |    
                                IComponent --+
                                             |
                                            IFocusable

A sub-interface implemented by components that can obtain input focus. This includes all Field components as well as some other components, such as Upload.

Focus can be set with focus. This interface does not provide an accessor that would allow finding out the currently focused component; focus information can be acquired for some (but not all) Field components through the IFocusListener and IBlurListener interfaces.


See Also: FieldEvents

Instance Methods [hide private]
 
focus(self)
Sets the focus to this component:
source code
 
getTabIndex(self)
Gets the tabulator index of the IFocusable component.
source code
 
setTabIndex(self, tabIndex)
Sets the tabulator index of the IFocusable component.
source code

Inherited from IComponent: addCallback, addListener, addStyleName, attach, childRequestedRepaint, detach, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeCallback, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible

Inherited from terminal.paintable.IPaintable: getDebugId, paint, requestRepaint, requestRepaintRequests, setDebugId

Inherited from terminal.variable_owner.IVariableOwner: changeVariables, isImmediate

Inherited from terminal.sizeable.ISizeable: getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidthUnits

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

focus(self)

source code 

Sets the focus to this component:

 loginBox = Form()
 loginBox.setCaption("Login")
 layout.addComponent(loginBox)

 # Create the first field which will be focused
 username = TextField("User name")
 loginBox.addField("username", username)

 # Set focus to the user name
 username.focus()

 password = TextField("Password")
 loginBox.addField("password", password)

 login = Button("Login")
 loginBox.getFooter().addComponent(login)

Notice that this interface does not provide an accessor that would allow finding out the currently focused component. Focus information can be acquired for some (but not all) IField components through the IFocusListener and IBlurListener interfaces.

See Also:
FieldEvents, FocusEvent, IFocusListener, BlurEvent, IBlurListener

getTabIndex(self)

source code 

Gets the tabulator index of the IFocusable component.

Returns:
tab index set for the IFocusable component

See Also: setTabIndex

setTabIndex(self, tabIndex)

source code 

Sets the tabulator index of the IFocusable component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index:

 loginBox = Form()
 loginBox.setCaption("Login")
 layout.addComponent(loginBox)

 # Create the first field which will be focused
 username = TextField("User name")
 loginBox.addField("username", username)

 # Set focus to the user name
 username.focus()

 password = TextField("Password")
 loginBox.addField("password", password)

 login = Button("Login")
 loginBox.getFooter().addComponent(login)

 # An additional component which natural focus order would
 # be after the button.
 remember = CheckBox("Remember me")
 loginBox.getFooter().addComponent(remember)

 username.setTabIndex(1)
 password.setTabIndex(2)
 remember.setTabIndex(3)  # Different than natural place
 login.setTabIndex(4)

After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.

If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.

A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.

Parameters:
  • tabIndex - the tab order of this component. Indexes usually start from 1. Zero means that default tab order should be used. A negative value means that the field should not be included in the tabbing sequence.

See Also: getTabIndex