我想獲得的「滾動條-Y」 qx.ui.list.List有沒有更好的方法來獲得子控件名稱?
使用createChildControl事件我怎麼能檢查小部件是一個名爲類的引用「滾動條-Y」 ?
到目前爲止,我發現了兩種方式,其中沒有一個似乎優雅,但似乎都完成工作
this.__list = new qx.ui.list.List()
this.__list.addListener("createChildControl", this.__onListCreateChildControl, this);
後來
__onListCreateChildControl: function (e){
debugger;
var child = e.getData();
if (child.constructor === qx.ui.core.scroll.ScrollBar && child.getOrientation() === "vertical") {
child.addListener("scroll", this.__onListScroll, this);
}
},
這隱含檢查。顯然,如果它是一個滾動條,它是垂直的,它就是我們的y滾動條。是的它看起來有點像鴨子,但我必須同時檢查
if (quacks like one && walks like one)
另一種方式是
__onListCreateChildControl: function (e){
debugger;
var child = e.getData();
if (child.$$subcontrol === 'scrollbar-y') {
child.addListener("scroll", this.__onListScroll, this);
}
},
使用內部變量$$子控件中。這工作正常,但它使用qooxdoo內部,這似乎是一個黑客。
P.S.我確實嘗試了getChildControl('scrollbar-y')的各個階段,但由於它是在「根據需要」的基礎上創建的,我總是得到空值。
但是,如果第二個參數不正確,調用'getChildControl('scrollbar-y')'應該強制創建子控件實例。當然,相應的DOM元素創建會延遲到小部件隊列運行。請參閱tinyurl base URI +/gusrrsf – level420
我的初始代碼與tinyurl/hxszabn類似。它沒有工作。試圖讓窗口上的孩子控制出現。出現在列表上。每當我得到空。現在我由於其他原因繼承了qx.ui.list.List,並在子類構造函數中使用了getChildControl('scrollbar-y')。現在它可以工作。 – voger