diff --git a/editor/js/UI.js b/editor/js/UI.js index 2db21d7ce3e41074c40f8a33378cc4f0bed7332e..6859e680c20af51f80a8670b4ef2f87abeef6b2c 100644 --- a/editor/js/UI.js +++ b/editor/js/UI.js @@ -344,30 +344,49 @@ UI.Select.prototype.onChange = function ( callback ) { }; +// Checkbox -// Boolean +UI.Checkbox = function ( position ) { -UI.Boolean = function ( position ) { + UI.Element.call( this ); + + var scope = this; + + this.dom = document.createElement( 'input' ); + this.dom.type = 'checkbox'; + this.dom.style.position = position || 'relative'; - UI.Select.call( this, position ); + this.onChangeCallback = null; - this.setOptions( { 'true': 'true', 'false': 'false' } ); + this.dom.addEventListener( 'change', function ( event ) { + + if ( scope.onChangeCallback ) scope.onChangeCallback(); + + }, false ); return this; }; -UI.Boolean.prototype = Object.create( UI.Select.prototype ); +UI.Checkbox.prototype = Object.create( UI.Element.prototype ); -UI.Boolean.prototype.getValue = function () { +UI.Checkbox.prototype.getValue = function () { - return this.dom.value === 'true'; + return this.dom.checked; }; -UI.Boolean.prototype.setValue = function ( value ) { +UI.Checkbox.prototype.setValue = function ( value ) { + + this.dom.checked = value; + + return this; - this.dom.value = value.toString(); +}; + +UI.Checkbox.prototype.onChange = function ( callback ) { + + this.onChangeCallback = callback; return this; diff --git a/editor/js/ui/Sidebar.Properties.Material.js b/editor/js/ui/Sidebar.Properties.Material.js index 2f6aee1a7192f34748a80ce6a47ed597aaf2238e..00da28667b68a1997a2e8d5f6852ba27e953b7a0 100644 --- a/editor/js/ui/Sidebar.Properties.Material.js +++ b/editor/js/ui/Sidebar.Properties.Material.js @@ -176,7 +176,7 @@ Sidebar.Properties.Material = function ( signals ) { // transparent var materialTransparentRow = new UI.Panel(); - var materialTransparent = new UI.Boolean( 'absolute' ).setValue( false ).setLeft( '90px' ).onChange( update ); + var materialTransparent = new UI.Checkbox( 'absolute' ).setValue( false ).setLeft( '90px' ).onChange( update ); materialTransparentRow.add( new UI.HorizontalRule(), new UI.Text().setValue( 'Transparent' ).setColor( '#666' ) ); materialTransparentRow.add( materialTransparent ); @@ -186,7 +186,7 @@ Sidebar.Properties.Material = function ( signals ) { // wireframe var materialWireframeRow = new UI.Panel(); - var materialWireframe = new UI.Boolean( 'absolute' ).setValue( false ).setLeft( '90px' ).onChange( update ); + var materialWireframe = new UI.Checkbox( 'absolute' ).setValue( false ).setLeft( '90px' ).onChange( update ); materialWireframeRow.add( new UI.HorizontalRule(), new UI.Text().setValue( 'Wireframe' ).setColor( '#666' ) ); materialWireframeRow.add( materialWireframe ); diff --git a/editor/js/ui/Sidebar.Properties.Object3D.js b/editor/js/ui/Sidebar.Properties.Object3D.js index 0bf8ec5e9d0320634b4fdfc71ccecbc6e6a76105..09f4caf08a421b800dc6635347fda62950be5548 100644 --- a/editor/js/ui/Sidebar.Properties.Object3D.js +++ b/editor/js/ui/Sidebar.Properties.Object3D.js @@ -66,7 +66,7 @@ Sidebar.Properties.Object3D = function ( signals ) { // visible var objectVisibleRow = new UI.Panel(); - var objectVisible = new UI.Boolean( 'absolute' ).setLeft( '90px' ).setWidth( '50px' ).onChange( update ); + var objectVisible = new UI.Checkbox( 'absolute' ).setLeft( '90px' ).onChange( update ); objectVisibleRow.add( new UI.HorizontalRule(), new UI.Text().setValue( 'Visible' ).setColor( '#666' ) ); objectVisibleRow.add( objectVisible );