Below is an example demonstrating how to construct a simple dialog with an image that allows detecting interaction with pixels, name it so its position is stored uniquely from other script constructed dialogs, and size it according to the image.
// DAZ Studio version 4.11.0.37 filetype DAZ Script // Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sFileName ){ /*********************************************************************/ // String : A function for retrieving a translation if one exists function text( sText ) { // If the version of the application supports qsTr() if( typeof( qsTr ) != "undefined" ){ // Return the translated (if any) text return qsTr( sText ); } // Return the original text return sText; }; /*********************************************************************/ // void : A function for debugging cursor postion in the context of a widget function debugWidgetCursorPosition( wWidget, sSignal ) { // If the application version is 4.11.0.35 or newer if( App.version64 >= 0x0004000b00000023 ){ // Get the global cursor position var pntGlobalCursorPos = (new Point).cursorPos(); // Get the cursor position in the context of the widget var pntWidgetCursorPos = wWidget.mapFromGlobal( pntGlobalCursorPos ); print( sSignal, "x:", pntWidgetCursorPos.x, ", y:", pntWidgetCursorPos.y ); } }; /*********************************************************************/ // void : A function for handling when a button is pressed // 'this' is assumed to be the button that was pressed function handleButtonPressed() { debugWidgetCursorPosition( this, "Pressed" ); }; /*********************************************************************/ // void : A function for handling when a button is released // 'this' is assumed to be the button that was released function handleButtonReleased() { debugWidgetCursorPosition( this, "Released" ); }; /*********************************************************************/ // void : A function for handling when a button is clicked // 'this' is assumed to be the button that was clicked function handleButtonClicked() { debugWidgetCursorPosition( this, "Clicked" ); }; /*********************************************************************/ // Define the template for What's This text var sWhatsThis = "<b>%1</b><br/><br/>%2"; // 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 Image"; // 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 pixmap for the image var pixImage = new Pixmap( sFileName ); // Create a button and assign a pixmap var wButton = new DzPushButton( wDlg ); wButton.objectName = "ImageButton"; // If the application version is 4.11.0.38 or newer if( App.version64 >= 0x0004000b00000026 ){ // Adjust the size of the button to match the size of the pixmap wButton.sizedFromIcon = true; } // If the application version is 4.11.0.43 or newer if( App.version64 >= 0x0004000b0000002b ){ // Adjust the size of the button to match the size of the pixmap wButton.collapseEmptySpace = true; } //wButton.buttonstyle = DzPushButton.BCustom; wButton.primitive = "Frame"; wButton.pixmap = pixImage; //wButton.text = "Test"; //wButton.displayDownArrow = true; wButton.pressed.connect( wButton, handleButtonPressed ); wButton.released.connect( wButton, handleButtonReleased ); wButton.clicked.connect( wButton, handleButtonClicked ); // Add the button to the dialog wDlg.addWidget( wButton, 0, DzWidget.AlignCenter ); // Get the minimum size of the dialog var sizeHint = oDlgWgt.minimumSizeHint; // Set the fixed size of the dialog wDlg.setFixedSize( sizeHint.width, sizeHint.height ); // Set the text on the accept button wDlg.setAcceptButtonText( text( "&Close" ) ); // Hide the cancel button wDlg.showCancelButton( false ); // Display the dialog wDlg.exec(); // Finalize the function and invoke })( "D:/temp/test.png" );