Base UI list component class that has to be extended with a concrete list component implementation. The list component visualizes list data model (zebkit.data.ListModel).

Constructor:
zebkit.ui.BaseList ([m], [b])

Parameters:
  • [m] <zebkit.data.ListModel | Array>

    a list model that should be passed as an instance of zebkit.data.ListModel or as an array.

  • [b] <Boolean>

    true if the list navigation has to be triggered by pointer cursor moving




protected void $pointerMoved (x, y)
protected void $select (o)
protected <Integer> calcMaxItemSize ( )
protected void drawView (g, id, x, y, w, h)
protected void drawViewAt (g, id, index)
protected <Integer> findSelectable (off, d)
protected void fireSelected (prev)
public <Integer> getItemIdxAt (x, y)
public <Object> getItemLocation (i)
public <Object> getItemSize (i)
public <Object> getSelected ( )
public <Object> getValue ( )
public <Boolean> isItemSelectable (i)
public <Boolean> isSelected (i)
public void keyTyped (e)
protected <Integer> lookupItem (ch)
protected <Integer> pageSize (d)
protected void repaintByOffsets (p, n)
public void select (index)
public void setModel (m)
public void setPosition (c)
public <Integer> setValue (v)
public void setViewProvider (v)
public void setViews (views)


Inherited methods:
$setConstraints(c)    add(constr, d)    byConstraints([p], c)    byPath(path, [cb])    calcPreferredSize(target)    doLayout( )    fire(event, [path], [params])    focused( )    getBottom( )    getCanvas( )    getComponentAt(x, y)    getHorPadding( )    getLeft( )    getLines( )    getLineSize(l)    getMaxOffset( )    getPreferredSize( )    getRight( )    getTop( )    getVerPadding( )    hasFocus( )    indexOf(c)    insert(i, constr, d)    invalidate( )    invalidateLayout( )    kidAdded(index, constr, l)    kidRemoved(i, l)    laidout( )    load(JSON)    off([eventName], [path], [cb])    on([eventName], [path], cb)    paintComponent(g)    paintViewAt(g, ax, ay, v)    properties([path], props)    property([path], name, value)    recalc( )    relocated(px, py)    remove(c)    removeAll( )    removeAt(i)    removeByConstraints(ctr)    removeMe([after])    repaint([x], [y], [w], [h])    requestFocus( )    requestFocusIn([timeout])    resized(pw, ph)    setAt(i, d)    setBackground(v)    setBorder([v])    setBottomPadding(bottom)    setBounds(x, y, w, h)    setByConstraints(constr, c)    setConstraints(ctr)    setEnabled(b)    setId(id)    setKids(a)    setLayout(m)    setLeftPadding(left)    setLocation(xx, yy)    setPadding(v)    setParent(o)    setPreferredSize(w, h)    setProperties([path], props)    setRightPadding(right)    setSize(w, h)    setTopPadding(top)    setVisible(b)    toBack( )    toFront( )    toPreferredHeight( )    toPreferredSize( )    toPreferredWidth( )    toView(target)    validate( )    validateMetric( )    vrp( )   


protected void $pointerMoved (x, y)

Called when a pointer (pointer or finger on touch screen) is moved to a new location


Parameters:
  • x <Integer>

    a pointer x coordinate

  • y <Integer>

    a pointer y coordinate

protected void $select (o)

Select the given list item. The method is called when an item selection is triggered by a user interaction: key board, or pointer


Parameters:
  • o <Integer>

    an item index

protected <Integer> calcMaxItemSize ( )

Calculate maximal width and maximal height the items in the list have


Returns: <Integer>

a max items size

protected void drawView (g, id, x, y, w, h)

Draw the given list view element identified by the given id at the specified location.


Parameters:
  • g <CanvasRenderingContext2D>

    a graphical context

  • id <String>

    a view id

  • x <Integer>

    a x coordinate the view has to be drawn

  • y <Integer>

    a y coordinate the view has to be drawn

  • w <Integer>

    a view width

  • h <Integer>

    a view height

protected void drawViewAt (g, id, index)

Draw the given list view element identified by the given id on the given list item.


Parameters:
protected <Integer> findSelectable (off, d)

Find a next selectable list item starting from the given offset with the specified direction


Parameters:
  • off <Integer>

    a start item index to perform search

  • d <Integer>

    a direction increment. Cam be -1 or 1


Returns: <Integer>

a next selectable item index

protected void fireSelected (prev)

Fire selected event


Parameters:
  • prev <Integer | Null>

    a previous selected item index. null if the same item has been re-selected

public <Integer> getItemIdxAt (x, y)

Detect an item by the specified location


Parameters:
  • x <Integer>

    a x coordinate

  • y <Integer>

    a y coordinate


Returns: <Integer>

a list item that is located at the given position. -1 if no any list item can be found.

public <Object> getItemLocation (i)

Return the given list item location.


Parameters:
  • i <Integer>

    a list item index


Returns: <Object>

a location of the list item. The result is object that has the following structure: { x:{Integer}, y:{Integer} }

public <Object> getItemSize (i)

Return the given list item size.


Parameters:
  • i <Integer>

    a list item index


Returns: <Object>

a size of the list item. The result is object that has the following structure: { width:{Integer}, height:{Integer} }

public <Object> getSelected ( )

Get selected list item


Returns: <Object>

an item

public <Object> getValue ( )

Get the list component selected item


Returns: <Object>

a selected item

public <Boolean> isItemSelectable (i)

Test if the given item is selectable.


Parameters:
  • i <Integer>

    an item index


Returns: <Boolean>

true if the given item is selectable

public <Boolean> isSelected (i)

Test if the given list item is selected


Parameters:
  • i <Integer>

    an item index


Returns: <Boolean>

true if the item with the given index is selected

public void keyTyped (e)

Define key typed events handler


Parameters:
protected <Integer> lookupItem (ch)

Lookup a list item buy the given first character


Parameters:
  • ch <String>

    a first character to lookup


Returns: <Integer>

a position of found list item in the list or -1 if no item is found.

protected <Integer> pageSize (d)

The method returns the page size that has to be scroll up or down


Parameters:
  • d <Integer>

    a scrolling direction. -1 means scroll up, 1 means scroll down


Returns: <Integer>

a number of list items to be scrolled

protected void repaintByOffsets (p, n)

Force repainting of the given list items


Parameters:
  • p <Integer>

    an index of the first list item to be repainted

  • n <Integer>

    an index of the second list item to be repainted

public void select (index)

Select the given list item


Parameters:
  • index <Integer>

    an item index to be selected

public chainable setModel (m)

Set the list model to be rendered with the list component


Parameters:
public chainable setPosition (c)

Set the given position controller. List component uses position to track virtual cursor.


Parameters:
public <Integer> setValue (v)

Select the specified list item.


Parameters:
  • v <Object>

    a list item to be selected. Use null as the parameter value to clean an item selection


Returns: <Integer>

an index of a selected item

public chainable setViewProvider (v)

Set the list items view provider. Defining a view provider allows developers to customize list item rendering.


Parameters:
  • v <Object | Function>

    a view provider class instance or a function that says which view has to be used for the given list model data. The function has to satisfy the following method signature: "function(list, modelItem, index)"

@Override zebkit.ui.DecorationViews
public void setViews (views)

Sets the views for the list visual elements. The following elements are supported:

  • "select" - a selection view element
  • "topMarker" - a position marker view element that is rendered on top of list item
  • "marker" - a position marker view element

Parameters:
  • views <Object>

    view elements



Inherited attributes:
public zebkit.draw.View bg    public zebkit.draw.View border    public Boolean canHaveFocus    public Object constraints    public Integer height    public Boolean isEnabled    public Boolean isValid    public Boolean isVisible    public Array kids    public zebkit.layout.Layout layout    public zebkit.layout.Layoutable parent    public Integer width    public Integer x    public Integer y   



public <Boolean> isComboMode

Indicate the current mode the list items selection has to work

public <zebkit.data.ListModel> model

List model the component visualizes

public model

List model

public <zebkit.util.Position> position

Position manager.

protected <zebkit.ui.ScrollManager> scrollManager

Scroll manager

public <Integer> selectedIndex

Currently selected list item index




selected

Fire when a list item has been selected:

list.on("selected", function(src, prev) {
    ...
});

Parameters:
  • src <zebkit.ui.BaseList>

    a list that triggers the event

  • prev <Integer | Object>

    a previous selected index, return null if the selected item has been re-selected