Aargh, again I was too cavalier in posting this patch.  I'll be more
systematic in the future.  I've fixed some major typos that prevented
the patch from working, and also followed the coding-style guidelines
this time around.

Index: Story.js
===================================================================
--- Story.js    (revision 10958)
+++ Story.js    (working copy)
@@ -287,15 +287,70 @@
        }
 };

+//# In HTML terms, each tiddler has a child: <div class="toolbar">
+//# Return tiddler's first child "div" element with a class of
"toolbar"
+Story.prototype.findToolbar = function(e)
+{
+       var divs = e.getElementsByTagName("div");
+       for(var index=0; index<divs.length; index++) {
+               var div = divs[index];
+               if(div.className == "toolbar") {
+                       return div;
+               }
+       }
+       return null;
+};
+
+//# Unfortunately, instead of element.attribtes["href"] the DOM has
element.attributes[N].name=="commandname" and element.attributes
[N].value for some numerical N
+//# This makes the syntax a little more like element.attributes
["href"]
+Story.prototype.attributeNamed = function(e, name)
+{
+       var attribs = e.attributes;
+       for(var index=0; index<attribs.length; index++) {
+               var attrib = attribs[index];
+               if(attrib.name == name) {
+                       return attrib.value;
+               }
+       }
+       return null;
+};
+
+//Activate toolbar-button access keys when a tiddler gets mouse focus
+//# In HTML terms, each toolbar has a series of buttons: <a
href="javascript:;" title="Close this tiddler" class="button
command_closeTiddler" commandname="closeTiddler"
tiddler="GettingStarted">close</a>
+//# The buttons contain a commandname attribute, corresponding to a
member of config.commands
+//# Look up the accessKey field from that member, and copy it to the
buttons' accesskey property
+Story.prototype.addToolbarAccessKeys = function(e)
+{
+       var buttons = e.childNodes;
+       for(var index=0; index<buttons.length; index++) {
+               var button = buttons[index];
+               var commandname = story.attributeNamed(button, "commandname");
+               button.accessKey = config.commands[commandname].accessKey;
+       }
+};
+
+// Deactivate toolbar-button access keys when a tiddler loses mouse
focus
+//# Easiest to remove all access keys
+Story.prototype.removeToolbarAccessKeys = function(e)
+{
+       var buttons = e.childNodes;
+       for(var index=0; index<buttons.length; index++) {
+               var button = buttons[index];
+               button.accessKey = "";
+       }
+};
+
 //# Default tiddler onmouseover/out event handlers
 Story.prototype.onTiddlerMouseOver = function(e)
 {
        addClass(this, "selected");
+       story.addToolbarAccessKeys(story.findToolbar(this));
 };

 Story.prototype.onTiddlerMouseOut = function(e)
 {
        removeClass(this,"selected");
+       story.removeToolbarAccessKeys(story.findToolbar(this));
 };

 //# Default tiddler ondblclick event handler
Index: Lingo.js
===================================================================
--- Lingo.js    (revision 10978)
+++ Lingo.js    (working copy)
@@ -367,17 +367,20 @@

 merge(config.commands.closeTiddler,{
        text: "close",
-       tooltip: "Close this tiddler"});
+       tooltip: "Close this tiddler",
+       accessKey: "W"});

 merge(config.commands.closeOthers,{
        text: "close others",
-       tooltip: "Close all other tiddlers"});
+       tooltip: "Close all other tiddlers",
+       accessKey: "R"});

 merge(config.commands.editTiddler,{
        text: "edit",
        tooltip: "Edit this tiddler",
        readOnlyText: "view",
-       readOnlyTooltip: "View the source of this tiddler"});
+       readOnlyTooltip: "View the source of this tiddler",
+       accessKey: "E"});

 merge(config.commands.saveTiddler,{
        text: "done",


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to