/********************************************************************** This script is provided as part of the Daz Script Documentation. The contents of this script, and\or any portion thereof, may only be used in accordance with the following license: Creative Commons Attribution 3.0 Unported (CC BY 3.0) - http://creativecommons.org/licenses/by/3.0 To contact Daz 3D or for more information about Daz Script visit the Daz 3D website: - http://www.daz3d.com **********************************************************************/ // Source: /public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general_ui/simple_dialog/start // Define an anonymous function; // serves as our main loop, // limits the scope of variables (function(){ // Get the current style var oStyle = App.getStyle(); // Get the height for buttons var nBtnHeight = oStyle.pixelMetric( "DZ_ButtonHeight" ); // Create a basic dialog var wDlg = new DzBasicDialog(); // Get the wrapped widget for the dialog var oDlgWgt = wDlg.getWidget(); // Set the title of the dialog wDlg.caption = "My Simple Test"; // Strip the space for a settings key var sKey = wDlg.caption.replace( / /g, "" ) + "Dlg"; // Set an [unique] object name on the wrapped dialog widget; // this is used for recording position and size separately // from all other [uniquely named] DzBasicDialog instances oDlgWgt.objectName = sKey; // Create a color widget var wColorWgt = new DzColorWgt( wDlg ); wColorWgt.setFixedHeight( nBtnHeight ); // Add the widget to the dialog wDlg.addWidget( wColorWgt ); // Get the minimum size of the dialog var sizeHint = oDlgWgt.minimumSizeHint; // Set the fixed size of the dialog wDlg.setFixedSize( sizeHint.width, sizeHint.height ); // If the user accepts the dialog if( wDlg.exec() ){ // Get the color from the widget var clrAccepted = wColorWgt.value; // Do... something print( "R:", clrAccepted.red, "G:", clrAccepted.green, "B:", clrAccepted.blue ); // If the user rejects the dialog } else { // Do... something else print( "User cancelled." ); } // Finalize the function and invoke })();