Below is an example demonstrating how you can list the keyboard accelerators (aka “shortcuts”) for all known actions, via script.
// DAZ Studio version 4.6.2.118 // Define an anonymous function; // serves as our main loop, // limits the scope of variables (function(){ /*********************************************************************/ // 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; }; /*********************************************************************/ // Array<String> : A function to get a list of action accelerators and names function getActionShortcuts( sFormat, bCustom ) { // Get the action manager var oActionMgr = MainWindow.getActionMgr(); // If we do not have an action manager if( !oActionMgr ){ // We are done... return []; } // Define a regular expression for stripping accelerators from the label var regxAccelerator = new RegExp( "&(.)", "g" ); // Get the number of actions var nActions = (bCustom != true ? oActionMgr.getNumActions() : oActionMgr.getNumCustomActions()); // Define a pre-sized array var aResults = new Array( nActions ); // Declare working variables var vAction; var sShortcut, sText; // Iterate over the actions for( var i = 0; i < nActions; i += 1 ){ // Get the 'current' action vAction = (bCustom != true ? oActionMgr.getAction( i ) : oActionMgr.getCustomActionText( i )); // Get the shortcut sShortcut = (bCustom != true ? vAction.shortcut.toString() : oActionMgr.getCustomActionShortcut( i )); // If the action does not have a shortcut if( sShortcut.isEmpty() ){ // Next!! continue; } // Get the text; strip the accelerator sText = (bCustom != true ? vAction.text.replace( regxAccelerator, "$1" ) : oActionMgr.getCustomActionText( i ).replace( regxAccelerator, "$1" )); // Collect the string aResults[i] = String( sFormat ) .arg( sShortcut ) .arg( sText.replace( regxAccelerator, "$1" ) ); } // Return the results; strip empty elements return aResults.filter( Boolean ); }; /*********************************************************************/ // String : A function to convert an enumerated value to a string function getViewportModifierMouseShortcutString( nModifierMouseAccel ) { // Define common strings var sLMB = "LMB"; var sMMB = "MMB"; var sRMB = "RMB"; var sCmd = "Cmd"; var sCtrl = "Ctrl"; var sControl = (App.platform() == DzApp.MacOSX) ? sCmd : sCtrl; var sShift = "Shift"; var sAlt = "Alt"; // Return the string conversion of the enumerated value switch( nModifierMouseAccel ){ case DzViewportMgr.LeftClick: return sLMB; case DzViewportMgr.RightClick: return sRMB; case DzViewportMgr.MidClick: return sMMB; case DzViewportMgr.AltLeftClick: return sAlt + "+" + sLMB; case DzViewportMgr.AltRightClick: return sAlt + "+" + sRMB; case DzViewportMgr.AltMidClick: return sAlt + "+" + sMMB; case DzViewportMgr.CtrlLeftClick: return sControl + "+" + sLMB; case DzViewportMgr.CtrlRightClick: return sControl + "+" + sRMB; case DzViewportMgr.CtrlMidClick: return sControl + "+" + sMMB; case DzViewportMgr.ShiftLeftClick: return sShift + "+" + sLMB; case DzViewportMgr.ShiftRightClick: return sShift + "+" + sRMB; case DzViewportMgr.ShiftMidClick: return sShift + "+" + sMMB; case DzViewportMgr.CtrlAltLeftClick: return sControl + "+" + sAlt + "+" + sLMB; case DzViewportMgr.CtrlAltRightClick: return sControl + "+" + sAlt + "+" + sRMB; case DzViewportMgr.CtrlAltMidClick: return sControl + "+" + sAlt + "+" + sMMB; case DzViewportMgr.CtrlShiftLeftClick: return sControl + "+" + sShift + "+" + sLMB; case DzViewportMgr.CtrlShiftRightClick: return sControl + "+" + sShift + "+" + sRMB; case DzViewportMgr.CtrlShiftMidClick: return sControl + "+" + sShift + "+" + sMMB; case DzViewportMgr.AltShiftLeftClick: return sAlt + "+" + sShift + "+" + sLMB; case DzViewportMgr.AltShiftRightClick: return sAlt + "+" + sShift + "+" + sRMB; case DzViewportMgr.AltShiftMidClick: return sAlt + "+" + sShift + "+" + sMMB; case DzViewportMgr.CtrlAltShiftLeftClick: return sControl + "+" + sAlt + "+" + sShift + "+" + sLMB; case DzViewportMgr.CtrlAltShiftRightClick: return sControl + "+" + sAlt + "+" + sShift + "+" + sRMB; case DzViewportMgr.CtrlAltShiftMidClick: return sControl + "+" + sAlt + "+" + sShift + "+" + sMMB; default: return ""; } }; /*********************************************************************/ // String : A function to convert an enumerated value to a string function getViewportOperationShortcutString( nViewOperation ) { // Get the viewport manager var oViewportMgr = MainWindow.getViewportMgr(); // If we do not have a viewport manager if( !oViewportMgr ){ // We are done... return ""; } // Get the enumerated modifier + mouse button accelerator var nModifierMouseAccel = oViewportMgr.getMouseBtnAccelerator( nViewOperation ); // Return the string version of the enumerated value return getViewportModifierMouseShortcutString( nModifierMouseAccel ); }; /*********************************************************************/ // Array<String> : A function to get a list of shortcuts for viewport operations function getViewportOperationShortcuts( sFormat ) { // Define a pre-sized array var aResults = new Array( 7 ); // Set the entry for orbit aResults[0] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.OrbitCamera ) ) .arg( text( "Orbit Camera" ) ); // Set the entry for rotate aResults[1] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.RotateCamera ) ) .arg( text( "Rotate Camera" ) ); // Set the entry for pan aResults[2] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.PanCamera ) ) .arg( text( "Pan Camera") ); // Set the entry for dolly aResults[3] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.DollyCamera ) ) .arg( text( "Dolly Camera" ) ); // Set the entry for bank aResults[4] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.BankCamera ) ) .arg( text( "Bank Camera" ) ); // Set the entry for dolly zoom aResults[5] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.ZoomDCamera ) ) .arg( text( "Dolly Zoom Camera" ) ); // Set the entry for focal zoom aResults[6] = String( sFormat ) .arg( getViewportOperationShortcutString( DzViewportMgr.ZoomFCamera ) ) .arg( text( "Focal Zoom Camera" ) ); // Return the results return aResults; }; /*********************************************************************/ // Get the current style var oStyle = App.getStyle(); // Get the general margin var nMargin = oStyle.pixelMetric( "DZ_GeneralMargin" ); // Create a new dialog var wDlg = new DzBasicDialog(); wDlg.caption = text( "Accelerators" ); // Create a group box var wViewportGB = new DzVGroupBox( wDlg ); // Set the title wViewportGB.title = text( "Viewport :" ); // Set the margin wViewportGB.insideMargin = nMargin; // Set the spacing wViewportGB.insideSpacing = nMargin; // Add it to the dialog wDlg.addWidget( wViewportGB, 0 ); // Define the formatting var sStart = "<table>"; var sLine = "<tr><td align='center'>%1</td><td> : </td><td>%2</td></tr>"; var sEnd = "</table>"; // Get whether or not we can use text interaction flag enumerations var bHasTextInteractionFlags = (App.version64 >= 0x000400090003005a); var nTextBrowser = (bHasTextInteractionFlags ? DzLabel.TextBrowserInteraction : 13); // Create a label var wLbl = new DzLabel( wViewportGB ); // Populate it with viewport shortcuts wLbl.text = sStart + getViewportOperationShortcuts( sLine ).join( "\n" ) + sEnd; // Set text interaction flags wLbl.textInteractionFlags = nTextBrowser; // Create a group box var wActionsGB = new DzVGroupBox( wDlg ); // Set the title wActionsGB.title = text( "Actions :" ); // Set the margin wActionsGB.insideMargin = nMargin; // Set the spacing wActionsGB.insideSpacing = nMargin; // Add it to the dialog wDlg.addWidget( wActionsGB, 1 ); // Create a scroll area var wScroll = new DzScrollArea( wActionsGB ); // Hide the horizontal scroll bar wScroll.setHorizontalScrollbarDisplay( false ); // Hide the frame wScroll.hideFrame(); // Get the shortcuts for actions var aShortcuts = getActionShortcuts( sLine, false ); // Append the shortcuts for custom actions aShortcuts = aShortcuts.concat( getActionShortcuts( sLine, true ) ); // Sort the list aShortcuts.sort(); // Create a label wLbl = new DzLabel( wScroll ); // Populate it with the results wLbl.text = sStart + aShortcuts.join( "\n" ) + sEnd; // Set text interaction flags wLbl.textInteractionFlags = nTextBrowser; // Set the widget for the scroll area wScroll.setWidget( wLbl ); // Change the label on the accept button wDlg.setAcceptButtonText( text( "&OK" ) ); // Hide the cancel button wDlg.showCancelButton( false ); // Get the wrapped widget var oWidget = wDlg.getWidget(); // Strip spaces for a settings key var sKey = wDlg.caption.replace( / /g, "" ) + "Dlg"; // Set a [unique] object name on the wrapped dialog widget; // this is used for recording position and size separately // from all other [uniquely named] DzBasicDialog instances oWidget.objectName = sKey; // Get the minimum size hint for the dialog var sizeHint = oWidget.minimumSizeHint; // Define the fixed width var nFixedWidth = 270; // Define the fixed height var nFixedHeight = Math.min( Math.max( sizeHint.height, 500 ), 600 ); // Set the fixed size of the dialog wDlg.setFixedSize( nFixedWidth, nFixedHeight ); // Show the dialog wDlg.exec(); // Finalize the function and invoke })();