closure-library始める4 uiコンポーネント作ってみた
いやね、Containerのサンプル見たら、HorizontalのコンテナにControlをaddChildする前に、addClassName("goog-inline-block")してて、そこコメントアウトしたら横に並ばず...。
goog.provide('hoge.HBox'); goog.require('goog.ui.Container'); goog.require('goog.style'); hoge.HBox = function(opt_renderer,opt_domHelper){ goog.base(this,goog.ui.Container.Orientation.HORIZONTAL,opt_renderer,opt_domHelper); }; goog.inherits(hoge.HBox,goog.ui.Container); hoge.HBox.prototype.addChild = function(child, opt_render){ goog.base(this,'addChild',child, opt_render); if(child.getElement()){ goog.style.setInlineBlock(child.getElement()); } }; hoge.HBox.prototype.addChildAt = function(control, index, opt_render){ goog.base(this,'addChildAt',control, index, opt_render); if(control.getElement()){ goog.style.setInlineBlock(control.getElement()); } };