Author: ptw
Date: 2007-10-26 13:20:28 -0700 (Fri, 26 Oct 2007)
New Revision: 7024

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzCommand.lzs
Log:
Change 20071026-ptw-V by [EMAIL PROTECTED] on 2007-10-26 15:54:26 EDT
    in /Users/ptw/OpenLaszlo/ringding-2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Define Undefined instance variable in LzCommand

Bugs Fixed:
LPP-4590 'DHTML: Javascript error if menu Command missing "key" attribute'

Technical Reviewer: promanik (Message-Id: <[EMAIL PROTECTED]>)
QA Reviewer: sosullivan (pending)
Doc Reviewer: ben (pending)

Details:
    Test for LzCommand#keys being null before using it.  Also finished
    implementation of DisplayKeys.  Documented that LZCommand#keys can
    be null.

    Question for the doc reviewer:  In the command open tag, you
    specify the shortcut key combination with the attribute `key`, but
    this is stored as the attribute `keys`.  What is the proper way to
    document this?  I believe the `keys` attribute should be private
    and I should be documenting the "virtual" attribute `key`
    instead.  Or should I be filing an API change request to rename
    the `keys` attribute to `key`?

Tests:
    Test case from bug no longer gets reported error.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzCommand.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzCommand.lzs      2007-10-26 
20:04:17 UTC (rev 7023)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzCommand.lzs      2007-10-26 
20:20:28 UTC (rev 7024)
@@ -47,9 +47,9 @@
 /** array of keys (strings) that, when pressed together,
   * cause the onselect event of the command to be sent. For example:
   * setAttribute('key', ['a', 'shift']) or setKeys(['j', 'control'])
-  * @type [String]
+  * @type [String]?
   */
-var keys;
+var keys = null;
 setters.key = "setKeys";
 
 /**
@@ -79,26 +79,34 @@
 }
 
 /**
+ * Mapping from key names to display strings used by keysToString
+ */
+static var DisplayKeys = {control:"Ctrl", shift:"Shift", alt:"Alt"};
+
+/**
   * This is a utility method that returns a string that describes the key 
   * combination that causes this command to be invoked.
   * 
   * @return String: A string containing the key combination that causes this
   * command to be invoked.
   */
-function keysToString ( ){
-    var DisplayKeys = {control:"Ctrl", shift:"Shift", alt:"Alt"}
-    var s= ""
-    var k = ""
-    var l= this.keys.length;
-    for( var i=0; i<l-1; i++ ){
-        k = this.keys[i];
-        if (k=="Control") k="Ctrl";
+function keysToString ( ) {
+  var s= "";
+  var keys = this.keys;
+  if (keys) {
+    var dk = LzCommand.DisplayKeys;
+    var k = "";
+    var l= keys.length - 1;
+    for (var i = 0; i < l; i++) {
+        k = keys[i];
+        if (k in dk) k = dk[k];
         s = s + k + "+"
     }
-    k = this.keys[i];
-    if (k=="Control") k="Ctrl";
+    k = keys[i];
+    if (k in dk) k = dk[k];
     s = s + k;
-    return s;
+  }
+  return s;
 }
 
 }; // End of LzCommand


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to