浏览代码

fix toolbar toggle() not calling change callback

trethaller 5 年之前
父节点
当前提交
a6b3e84832
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      hide/comp/Toolbar.hx

+ 4 - 3
hide/comp/Toolbar.hx

@@ -31,11 +31,12 @@ class Toolbar extends Component {
 		if(label != null) {
 			new Element('<label>$label</label>').appendTo(e);
 		}
-		e.click(function(_) {
+		function tog() {
 			e.toggleClass("toggled");
 			this.saveDisplayState("toggle:" + icon, e.hasClass("toggled"));
 			if( onToggle != null ) onToggle(e.hasClass("toggled"));
-		});
+		}
+		e.click(function(_) tog());
 		e.appendTo(element);
 		if( defValue ) e.addClass("toggled");
 		var def = getDisplayState("toggle:" + icon);
@@ -43,7 +44,7 @@ class Toolbar extends Component {
 		if( def != defValue ) e.click();
 		return {
 			element : e,
-			toggle : function(b) e.toggleClass("toggled",b),
+			toggle : function(b) tog(),
 			isDown: function() return e.hasClass("toggled") };
 	}