/************************************************************************** * * @@@BUILDINFO@@@ 96shortcutPrefs-2.jsx 2.0.1.62 22-Mar-2007 * Copyright 2006-2007 Adobe Systems Incorporated * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of * Adobe Systems Incorporated and its suppliers, if any. The intellectual * and technical concepts contained herein are proprietary to Adobe Systems * Incorporated and its suppliers and may be covered by U.S. and Foreign * Patents,patents in process,and are protected by trade secret or copyright * law. Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained from * Adobe Systems Incorporated. **************************************************************************/ // Each Prefs object needs the following methods: // prefsObj.create (parentPane) - create the pane and return the Pane object. // pane.preProcess() - preprocess the pane just before being shown. // pane.layoutDone() - informs the pane that the initial layout is done (optional) // pane.postProcess() - do any work just before the pane is being hidden. // pane.store() - store the preferences. Return true if the Next Time dialog is needed. // pane.toDefault() - set back to default values // pane.cancelled() - Prefs dialog has been cancelled // On Windows, the "Cmd" modifier is mapped to the Ctrl modifier, so Ctrl-X combos end up as // Cmd-X combos on the Mac. var shortcutPrefs = {}; shortcutPrefs.create = function (parentPane) { this.pane = parentPane.add ( "group { \ orientation :'column', \ alignChildren : ['fill','fill'], \ visible : false, \ alignment : ['fill','fill'], \ list : ListBox { \ helpTip : '$$$/ESToolkit/PreferencesDlg/shortcutTitle=Keyboard Shortcuts', \ preferredSize : [365,270] \ }, \ options : Group { \ orientation : 'row', \ alignment : ['left','bottom'], \ modifiers : Group { \ orientation : 'column', \ alignment : ['left','top'], \ alignChildren : 'left', \ modShift : Checkbox { \ text : '$$$/ESToolkit/PreferencesDlg/ModShift=Shift', \ helpTip : '$$$/ESToolkit/PreferencesDlg/htModShift=SHIFT key' \ }, \ modCmd : Checkbox { \ text : '$$$/ESToolkit/PreferencesDlg/ModCtrl=Ctrl', \ helpTip : '$$$/ESToolkit/PreferencesDlg/htModCtrl=Ctrl key' \ }, \ modAlt : Checkbox { \ text : '$$$/ESToolkit/PreferencesDlg/ModAlt=Alt', \ helpTip : '$$$/ESToolkit/PreferencesDlg/htModAlt=ALT key' \ }, \ modCtrl : Checkbox { \ text : '$$$/ESToolkit/PreferencesDlg/ModCtrl=Ctrl', \ helpTip : '$$$/ESToolkit/PreferencesDlg/htModCtrl=Ctrl key', \ visible : false \ } \ }, \ keyset : Group { \ orientation : 'column', \ alignment : ['left','top'] \ newkeyset : Group { \ orientation : 'row', \ alignment : ['left','top'] \ keylist : DropDownList { \ }, \ btAssign : Button { \ text : '$$$/ESToolkit/PreferencesDlg/assignShortcut=Assign', \ helpTip : '$$$/ESToolkit/PreferencesDlg/hiAssignShortcut=Assign the shortcut.' \ }, \ btRemove : Button { \ text : '$$$/ESToolkit/PreferencesDlg/removeShortcut=Remove', \ helpTip : '$$$/ESToolkit/PreferencesDlg/htRemoveShortcut=Remove the shortcut.' \ } \ }, \ oldkeyset : StaticText { \ text : ' ', \ minimumSize : [ 100, 50 ], \ characters : 50 \ } \ } \ } \ }"); this.pane.modShift = this.pane.options.modifiers.modShift; this.pane.modCmd = this.pane.options.modifiers.modCmd; this.pane.modAlt = this.pane.options.modifiers.modAlt; this.pane.modCtrl = this.pane.options.modifiers.modCtrl; this.pane.keyList = this.pane.options.keyset.newkeyset.keylist; this.pane.btAssign = this.pane.options.keyset.newkeyset.btAssign; this.pane.btRemove = this.pane.options.keyset.newkeyset.btRemove; this.pane.oldKeyset = this.pane.options.keyset.oldkeyset; this.pane.keyList.minimumSize.width = 80; // On Windows, modCmd and modCtrl are the same, and only modCmd is displayed as modCtrl if (Folder.fs == "Macintosh") { this.pane.modAlt.text = localize ('$$$/ESToolkit/PreferencesDlg/ModOpt=Option'); this.pane.modAlt.helpTip = localize ('$$$/ESToolkit/PreferencesDlg/htModOpt=Option key'); this.pane.modCtrl.visible = true; this.pane.modCmd.text = ' '; this.pane.modCmd.text = localize( '$$$/ESToolkit/PreferencesDlg/ModCmd=Cmd' ); this.pane.modCmd.helpTip = localize( '$$$/ESToolkit/PreferencesDlg/htModCmd=Apple key' ); } this.loaded = false; this.pane.prefsObj = this; // the item that has the current assignment of a key this.usedItem = null; this.pane.preProcess = function() { // not there yet before final layout has been done if (this.list.onChange) this.list.onChange(); } this.pane.postProcess = function() {} this.pane.list.textWidth = 100; // set by layoutDone() // Set the text width of the menu text to be displayed this.pane.layoutDone = function() { this.prefsObj.load(); // This should be the longest to expect var str = shortcutPrefs.createDisplayKeyStr ("Shift+Ctrl+Alt+Cmd+X"); var list = this.list; var width = list.size.width; var shortcutWidth = list.graphics.measureString (str)[0]; list.textWidth = width - shortcutWidth; // Re-set the item texts var items = list.items; for (var i = 0; i < items.length; i++) list.setItemText (items [i]); } this.pane.cancelled = function() { var sel = this.list.selection; var items = this.list.items; for (var i = 0; i < items.length; i++) { var item = items [i]; item.shortcutInfo = item.originalShortcutInfo; this.list.setItemText (item); } if (sel) this.list.selection = sel; } this.pane.list.setItemText = function (item) { item.setTabbedText (item.menuText, this.textWidth, item.shortcutInfo.text); } this.pane.toDefault = function() { var items = this.list.items; var suffix = Folder.fs == 'Windows' ? '.win' : '.mac' for( var i=0; i= 0 ), alt : ( shortcutKeyStr.search( /alt/gi ) >= 0 ), cmd : ( shortcutKeyStr.search( /oscmnd/gi ) >= 0 ), ctrl : ( shortcutKeyStr.search( /ctrl/gi ) >= 0 ), text : this.createDisplayKeyStr (shortcutKeyStr), removed : false, newkey : false }; if (_win) // OSCmd == Ctrl on Windows shortcutInfo.cmd = shortcutInfo.ctrl = (shortcutInfo.cmd || shortcutInfo.ctrl); var parts = shortcutKeyStr.split('+'); if( parts.length > 0 ) shortcutInfo.key = parts[parts.length-1]; return shortcutInfo; } shortcutPrefs.createShortcutKeyStr = function( shortcutInfo ) { var keyStr = ''; if( shortcutInfo.shift ) keyStr += ( keyStr.length > 0 ? '+' : '' ) + 'Shift'; if( shortcutInfo.cmd ) keyStr += ( keyStr.length > 0 ? '+' : '' ) + 'OSCmnd'; if( shortcutInfo.alt ) keyStr += ( keyStr.length > 0 ? '+' : '' ) + 'Alt'; if (Folder.fs == "Macintosh" && shortcutInfo.ctrl ) keyStr += ( keyStr.length > 0 ? '+' : '' ) + 'Ctrl'; keyStr += ( keyStr.length > 0 ? '+' : '' ) + shortcutInfo.key; return keyStr; } shortcutPrefs.createDisplayKeyStr = function( shortcutKeyStr ) { var ret = ''; var entries = shortcutKeyStr.split('+'); for( var i=0; i 0 ) ret += '+'; if( Folder.fs == 'Windows' ) entries[i] = entries[i].replace( /OSCmnd/g, 'Ctrl' ) else { entries[i] = entries[i].replace( /OSCmnd/g, 'Cmd' ) entries[i] = entries[i].replace( /Alt/g, 'Opt' ) } var toLocalize = "$$$/CT/ExtendScript/UI/MenuShortcut" + entries [i] + "=" + entries [i]; ret += localize (toLocalize); } return ret; } shortcutPrefs.reflectShortcut = function( shortcutInfo ) { with( this.pane ) { modCmd.value = ( shortcutInfo ? shortcutInfo.cmd : false ); modShift.value = ( shortcutInfo ? shortcutInfo.shift : false ); modAlt.value = ( shortcutInfo ? shortcutInfo.alt : false ); modCtrl.value = ( shortcutInfo ? shortcutInfo.ctrl : false ); } var ddl = this.pane.keyList; var sel = null; if( shortcutInfo ) { for( var i=0; i < ddl.items.length; i++ ) { if( ddl.items[i].text == shortcutInfo.key ) { sel = ddl.items[i]; break; } } } ddl.selection = sel; this.updateButtons(); } shortcutPrefs.updateButtons = function() { var selItem = this.pane.list.selection; var selKey = this.pane.keyList.selection; // all UI: Enabled if anything selected at all, and not a submenu var uiEnabled = (selItem != null && selItem.menu.type == "command"); // Assign button var enabled = uiEnabled && (selKey != null); // Enable Assign if either a standard character together with a modifier, // or an F key i.e. a character with a length > 0 :) if (enabled) { var mods = this.pane.modCmd.value || this.pane.modShift.value || this.pane.modAlt.value || this.pane.modCtrl.value; var fkey = (selKey.text.length > 1); enabled = mods || fkey; } this.pane.btAssign.enabled = enabled; // Remove button enabled = uiEnabled && (selKey != null); // Enable if anything is assigned if (enabled) enabled = (selItem.shortcutInfo && selItem.shortcutInfo.text != ""); this.pane.btRemove.enabled = enabled; // Other UI if (!uiEnabled) this.pane.oldKeyset.text = ""; this.pane.modShift.enabled = this.pane.modCmd.enabled = this.pane.modAlt.enabled = this.pane.modCtrl.enabled = this.pane.keyList.enabled = uiEnabled; } shortcutPrefs.createMenuStructure = function( menu, level, pathStr ) { var struct = []; if( !menu ) menu = menus; if( !level ) level = 0; if( !pathStr || level == 0 ) pathStr = ''; for( var name in menu ) { if( menu[name] instanceof MenuElement ) { var text = ''; for( var m=0; m 0 ) menuPath += ' - '; menuPath += menuText; struct.push( { menu : menu[name], entryText : text, preferenceKey : menu[name].id.replace( /\//g, '_' ), pathString : menuPath } ); } else { var menuPath = pathStr; if( level == 0 ) menuPath = menuText; else { if( menuPath.length > 0 ) menuPath += ' - '; menuPath += menuText; } struct.push( { menu : menu[name], entryText : text, preferenceKey : menu[name].id.replace( /\//g, '_' ), pathString : menuPath } ); var sub = shortcutPrefs.createMenuStructure( menu[name], level+1, menuPath ); for( var i=0; i