Fabian Jakobs <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] schrieb:
>> On the one hand, I believe in giving the developer the freedom to do what
>> he wants (which, unfortunately, sometimes includes shooting himself in the
>> foot).  On the other hand, there's a lot to be said for consistency.  A
>> user shouldn't have to "know" the application to know how to use a
>> particular widget; it should work the same way in every application (with
>> some amount of configurability to allow for application differences).  It
>> wouldn't be obvious whether this tree is in "cell focus" mode or "row
>> focus" mode, and thus the keyboard behavior would be unknown.
>>
> This could easily be differentiated by the visual focus indicator. The table
> now focuses just one cell and highlights it. In Row focus mode the whole row
> would be focussed.

Fabian, I think I'm not going to add a provision for unmodified Left/Right to
move to parent/first child.  That capability is available with shifted
Left/Right.  It is, however, fairly easy for your app, should you really
decide that you need it, to subclass TreeVirtual and gain the required
functionality.  The following untested subclass is probably what you need.

qx.OO.defineClass("my.TreeVirtual", qx.ui.treevirtual.TreeVirtual,
function(headings)
{
  // Call our superclass constructor
  qx.ui.treevirtual.TreeVirtual.call(this, headings);
});

qx.Proto._onkeydown = function(evt)
{
  var identifier = evt.getKeyIdentifier();

  var consumed = false;
  var modifiers = evt.getModifiers();
  if (modifiers == 0)
  {
    switch (identifier)
    {
      case "Left":
      // Get the data model
      var dm = this.getDataModel();

      // Get the focused node
      var focusedRow = this.getFocusedRow();
      var treeCol = dm.getTreeColumn();
      var node = dm.getValue(treeCol, focusedRow);

      // If we're not at the top-level already...
      if (node.parentNodeId)
      {
        // Find out what rendered row our parent node is at
        var rowIndex = dm.getNodeRowMap()[node.parentNodeId];
      
        // Set the focus to our parent
        this.setFocusedCell(treeCol, rowIndex, true);
      }
      
      consumed = true;
      break;

      case "Right":
      // Get the data model
      var dm = this.getDataModel();

      // Get the focused node
      var focusedRow = this.getFocusedRow();
      var treeCol = dm.getTreeColumn();
      var node = dm.getValue(treeCol, focusedRow);

      // If we're on a branch and open/close is allowed...
      if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.BRANCH &&
          ! node.bHideOpenClose)
      {
        // ... then first ensure the branch is open
        if (! node.bOpened)
        {
          this.toggleOpened(node);
        }

        // If this node has children...
        if (node.children.length > 0)
        {
          // ... then move the focus to the first child
          this.moveFocusedCell(0, 1);
        }
      }
      
      consumed = true;
      break;
    }
  }

  // Was this one of our events that we handled?
  if (consumed)
  {
    // Yup.  Don't propagate it.
    evt.preventDefault();
    evt.stopPropagation();
  }
  else
  {
    // It's not one of ours.  Let our superclass handle this event
    qx.ui.treevirtual.TreeVirtual.prototype._onkeydown.call(this, evt);
  }
};


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to