ctr.md

2018-11-22 17:57 更新

ngui/ctr

empty

  • 這是一個常量空view xml,描述一個無子視圖的View

isEmpty(vx)

  • vx是否等于empty空視圖數(shù)據(jù)

New(vx[,parent[,...args]])

New(vx[,...args])

  • 通過vx描述數(shù)據(jù)創(chuàng)建視圖或視圖控制器

  • @arg vx {Object} view xml描述數(shù)據(jù)
  • @arg [parent] {View} 傳入父視圖時將新創(chuàng)建的視圖加入到它的結尾
  • @arg [...args] 視圖的構造參數(shù)
  • @ret {View|ViewController}

Example:

import { GUIApplication, ViewController, Root, Div } from 'ngui'
import 'ngui/http'
class MyCtr extends ViewController {
    loadView() {
        http.get('http://192.168.1.100:1026/README.md?param=' + this.message.param, bf=>{
            super.loadView(
                <Div width=100 height=100 backgroundColor="#f00">
                    ${bf.toString('utf8')}
                </Div>
            )
        })
    }
}
new GUIApplication().start(
    <Root>
        <ViewController vdata={ divWidth: 200, divCon: 'Hello' }>
            <Div width=%{vd.divWidth} height=100 backgroundColor="#000">
                %{vd.divCon}
            </Div>
        </ViewController>
        <MyCtr message={param:10} />
    </Root>
);

Class: ViewController

視圖控制器,與視圖綁定后視圖變成關鍵視圖,當前控制器有可稱為成員視圖控制器,

關鍵視圖下面所有后代視圖以及子視圖控制器都屬于這個作用域中的成員,

成員視圖的top屬性都指向當前綁定的關鍵視圖,成員視圖的topCtr以及子視圖控制器的parent都指向當前視圖控制器,

如果這些成員有具名的id,可以通過當前視圖控制器find(id)找到這些成員

ViewController.onLoadView

  • 載入視圖完成時觸發(fā)

ViewController.onViewDataChange

  • 視圖數(shù)據(jù)變化時觸發(fā),如果有視圖關注這個數(shù)據(jù),那么它也會發(fā)生改變

ViewController.onRemoveView

  • 綁定的視圖從父視圖刪除時觸發(fā)

ViewController.constructor([msg])

  • 構造函數(shù)

  • @arg [msg] {Object} 傳入可選的消息對像

ViewController.find(id)

  • 通過id查找成員視圖或成員控制器

ViewController.message

  • 控制器消息對像

ViewController.vdata

  • 控制器視圖數(shù)據(jù)

Get: ViewController.parent

  • 獲取父控制器

ViewController.view

  • 獲取或設置當前控制器綁定的視圖

ViewController.id

  • 獲取或設置一個id,這個id在同一個作用域中不能重復

  • 可通過id在父視圖控制器中查詢子控制器

ViewController.loadView(vx)

  • 通過vx數(shù)據(jù)載入視圖,這是個相當重要的方法,所有gui視圖載入創(chuàng)建以及視圖數(shù)據(jù)的綁定都在這個方法中完成,

重寫ViewController類與該方法來實現(xiàn)自定義組件。

  • 這個方法調(diào)用完成會觸發(fā)onloadView事件

View proxy events

  • 這些事件都為代理視圖的快捷方式,需要綁定的視圖支持這些事件

ViewController.onBack

ViewController.onClick

ViewController.onTouchstart

ViewController.onTouchmove

ViewController.onTouchend

ViewController.onTouchcancel

ViewController.onKeydown

ViewController.onKeypress

ViewController.onKeyup

ViewController.onKeyenter

ViewController.onFocus

ViewController.onBlur

ViewController.onHighlighted

ViewController.onFocusMove

ViewController.onScroll

ViewController.onActionKeyframe

ViewController.onActionLoop

ViewController.onWaitBuffer

ViewController.onReady

ViewController.onStartPlay

ViewController.onError

ViewController.onSourceEof

ViewController.onPause

ViewController.onResume

ViewController.onStop

ViewController.onSeek

View proxy methods and properties

  • 代理視圖的快捷方法與屬性

ViewController.action

ViewController.style

ViewController.visible

ViewController.receive

ViewController.class

ViewController.transition(style[,delay[,cb]])

ViewController.transition(style[,cb])

ViewController.show()

ViewController.hide()

ViewController.addClass(name)

ViewController.removeClass(name)

ViewController.toggleClass(name)

ViewController.remove()

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號