Hi Scott,

I would advise you to use a customized cell editor. Feel free to modify 
following code:

qx.Class.define("CellEditorTextField",
{
  extend : qx.ui.table.celleditor.TextField,


  members :
  {
    // overridden
    /**
     * TODOC
     *
     * @param cellInfo {var} TODOC
     * @return {var} TODOC
     */
    createCellEditor : function(cellInfo)
    {
      var cellEditor = this._createEditor();

      cellEditor.originalValue = cellInfo.value;

      if (cellInfo.value === null || cellInfo.value === undefined) {
        cellInfo.value = "";
      }

      cellEditor.setValue("" + cellInfo.value);

      cellEditor.addListener("appear", function() {
        cellEditor.selectAllText();
      });

      cellEditor.addListener("changeValue", function() {
        cellInfo.table.stopEditing();
      }, this);

      cellEditor.addListener("blur", function() {
        cellInfo.table.stopEditing();
      }, this);


      cellEditor.addListener("keypress", function(e)
      {
        var iden = e.getKeyIdentifier();
        var table = cellInfo.table;

        if (iden == "Tab")
        {
          e.stop();
          table.stopEditing();

          //# Ermittle nächste Spalte, wenn letzte Spalte, dann Zeilensprung 
fals möglich
          var nextCol = cellInfo.col;
          var nextRow = cellInfo.row;

          var editingFlag = true;

          if (cellInfo.col != table.getTableModel().getColumnCount() - 1) {
            nextCol++;
          }
          else
          {
            nextCol = 0;

            if (cellInfo.row != table.getTableModel().getRowCount() - 1)
            {
              nextRow++;
              editingFlag = false;
            }
          }

          table.setFocusedCell(nextCol, nextRow, true);
          table.updateContent();

          if (editingFlag === true)
          {
            var timer = qx.util.TimerManager.getInstance();

            timer.start(function(userData, timerId) {
              table.startEditing();
            }, 0, this, null, 0);
          }

          e.stopPropagation();
        }
        else if (iden == 'Enter')
        {
          table.stopEditing();
        }
      },
      this);

      return cellEditor;
    }
  }
});

To change custom cellrenderer just use setDataCellRenderer method. [1]

table.getTableColumnModel().setDataCellRenderer(0, new CellEditorTextField ());

regards Mustafa Sak

[1] 
http://demo.qooxdoo.org/devel/apiviewer/#qx.ui.table.columnmodel.Basic~setDataCellRenderer!method_public


Von: Scott Chapman [mailto:[email protected]]
Gesendet: Donnerstag, 14. Juni 2012 21:36
An: qooxdoo Development
Betreff: Re: [qooxdoo-devel] Can I make a table editable and only allow Ctrl-C?

I am starting out with this:

      var tableModel = this.getTableModel();
      tableModel.setColumnEditable(1, true);

      this.keypressListenerId = this.addListener("keypress", function(e){
        console.log("Event keypress e=" + e +
                    " identifier=" + e.getKeyIdentifier() +
                    " isShiftPressed=" + e.isShiftPressed()
                    );
      }, this);

But nothing is captured when you select text and then press a key.  It appears 
that the cell editor is capturing it.  How do I intercept that?

On Thu, Jun 14, 2012 at 12:10 PM, Scott Chapman 
<[email protected]<mailto:[email protected]>> wrote:
Is there a way to capture keystrokes and only allow Ctrl-C to get through to 
the table in editable mode?


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to