Class Delegate.TableView

TableView Delegate Interface.

the interface for controlling a TableView via a delegate.

Usage:

  •  local dUI = require 'dmc_ui'
    
     -- setup delegate object
     local delegate = {
       numberOfRows=function(self, tableview, section)
         -- return row data here
       end,
       onRowRender=function(self, event)
         -- create row view
       end,
       onRowUnrender=function(self, event)
         -- destroy row view
       end,
    
       shouldHighlightRow=function(self, event)
         return true
       end,
       willSelectRow=function(self, event)
         return event.index
       end,
     }
    
  •  local widget = dUI.newTableView()x
     widget.delegate = <delgate object>
    
  •  local dUI = require 'dmc_ui'
     local widget = dUI.newTableView{
       delegate=<delegate object>
     }

Methods

:numberOfRows (tableview, section) (required) asks the delegate to return the number of rows to be rendered.
:onRowRender (event) (required) asks the delegate to render the view for the row to be added to the display.
:onRowUnrender (event) (required) asks the delegate to unrender the view for the row to be removed from the display.
:shouldHighlightRow (event) (optional) asks delegate if specified row should be highlighted.
:didHighlightRow (event) (optional) informs delegate that row was highlighted.
:didUnhighlightRow (event) (optional) informs delegate that row has been unhighlighted.
:willSelectRow (event) (optional) asks delegate if specified row should be selected.
:didSelectRow (event) (optional) informs delegate that Nav Item was popped off stack.

Row-Object

.rowObjectMethods description of methods for a row object.


Methods

:numberOfRows (tableview, section)
(required) asks the delegate to return the number of rows to be rendered.

Parameters:

  • tableview the Widget.TableView object
  • section the section in question (not yet implemented)

Returns:

    number
:onRowRender (event)
(required) asks the delegate to render the view for the row to be added to the display.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.RENDER_ROW)
    • target object the Widget.TableView object
    • row object the row object rowObjectMethods
    • view object the row's Display Group, for visual items
    • index number the index of the row inside of the TableView
    • data tab a table for general data storage for the row.
:onRowUnrender (event)
(required) asks the delegate to unrender the view for the row to be removed from the display.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.UNRENDER_ROW)
    • target object the Widget.TableView object
    • row object the row object rowObjectMethods
    • view object the row's Display Group, for visual items
    • index number the index of the row inside of the TableView
    • data tab a table for general data storage for the row.
:shouldHighlightRow (event)
(optional) asks delegate if specified row should be highlighted. return true if row should be highlighted otherwise return false if not. if this method is not implemented, the default return value is true.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.SHOULD_HIGHLIGHT_ROW)
    • target object the TableView
    • index number the index of the row inside of the TableView
    • view object the row's Display Group, for visual items
    • data tab a table for general data storage for the row.

Returns:

    bool true if row should be highlighted.
:didHighlightRow (event)
(optional) informs delegate that row was highlighted.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.HIGHLIGHT_ROW)
    • target object the TableView
    • index number the index of the row inside of the TableView
    • view object the row's Display Group, for visual items
    • data tab a table for general data storage for the row.
:didUnhighlightRow (event)
(optional) informs delegate that row has been unhighlighted.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.UNHIGHLIGHT_ROW)
    • target object the TableView
    • index number the index of the row inside of the TableView
    • view object the row's Display Group, for visual items
    • data tab a table for general data storage for the row.
:willSelectRow (event)
(optional) asks delegate if specified row should be selected. this method must either return the index given (to select that row), an alternate index (to select another row) or nil to not select anything. if this method is not implemented, the default return value is the index passed in.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.WILL_SELECT_ROW)
    • target object the TableView
    • index number the index of the row inside of the TableView
    • view object the row's Display Group, for visual items
    • data tab a table for general data storage for the row.

Returns:

    index passed in, a different index, or nil
:didSelectRow (event)
(optional) informs delegate that Nav Item was popped off stack. tells delegate that this Nav Item was popped off of the navigation stack. the delegate can respond appropriately.

Parameters:

  • event the event table
    • name string the event name (TableView.EVENT)
    • type string the event type (TableView.SELECTED_ROW)
    • target object the TableView
    • index number the index of the row inside of the TableView
    • view object the row's Display Group, for visual items
    • data tab a table for general data storage for the row.

Row-Object

.rowObjectMethods
description of methods for a row object. the row object within the onRender/onUnrender has methods which can be used to modify some of the row attributes.

Fields:

  • setBackgroundColor function sets the background color of the row
  • setLineColor function sets the line color of the row
generated by LDoc 1.4.3 Last updated 2015-05-14 11:55:05