How to avoid the cell editor on a double click?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to avoid the cell editor on a double click?

Jörg Sawatzki
Hey,

usually, when double clicking an editable cell in a table, a cell editor
pops up, which is mostly fine. In my web based file manager the user
should be able to right click on a cell and then select "Rename" to
start the cell editor to rename the selected file. So, in short: Let
cellDblClick open the file and only start the cell editor when I
manually call table.startEditing() - any idea how to do this?
e.preventDefault() for the cellDblClick event does not work...

Thanks in advance

Jörg


------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

Derrell Lipman
On Tue, May 11, 2010 at 19:44, Jörg Sawatzki <[hidden email]> wrote:
Hey,

usually, when double clicking an editable cell in a table, a cell editor
pops up, which is mostly fine. In my web based file manager the user
should be able to right click on a cell and then select "Rename" to
start the cell editor to rename the selected file. So, in short: Let
cellDblClick open the file and only start the cell editor when I
manually call table.startEditing() - any idea how to do this?
e.preventDefault() for the cellDblClick event does not work...

I believe the action you're experiencing is caused by the qx.ui.table.pane.Scroller's _onDblclickPane() method. To avoid that action, while still allowing manually beginning editing, you can subclass qx.ui.table.pane.Scroller and override the _onDblclickPane() method. You probably want to do everything that's in that small method except for the call to this.startEditing().

Then, in order to use your subclass custom.Scroller as the the table pane scroller class, you create a small function that instantiates your class and put it in the 'custom' parameter to the constructor to Table:

var custom =
{
  tablePaneScroller : function(obj)
  {
    return new custom.Scroller(obj);
  }
}

var table = new qx.ui.table.Table(dataModel, custom);


Hope that helps.

Derrell

------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

rsantiagopaz
In reply to this post by Jörg Sawatzki
Jörg  I believe mabe you can use for example something like

tableModel.setColumnEditable(0, true);
table.startEditing();

on click select rename.


And use the Table "dataEdited" event to set
tableModel.setColumnEditable(0, false);

I use somthing like this in one application
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

Jörg Sawatzki
Hey guys,

thanks for your help so far. Gonna try both solution and if nothing
suits my needs I will just ask the user for a new name in a popup :)

Thanks once again

Jörg

Am Mittwoch, den 12.05.2010, 07:05 -0700 schrieb rsantiagopaz:

> Jörg  I believe mabe you can use for example something like
>
> tableModel.setColumnEditable(0, true);
> table.startEditing();
>
> on click select rename.
>
>
> And use the Table "dataEdited" event to set
> tableModel.setColumnEditable(0, false);
>
> I use somthing like this in one application



------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

Derrell Lipman
On Wed, May 12, 2010 at 15:56, Jörg Sawatzki <[hidden email]> wrote:
Hey guys,

thanks for your help so far. Gonna try both solution and if nothing
suits my needs I will just ask the user for a new name in a popup :)

Jörg, rsantiagopaz's suggestion is better than mine. Set each column to not be editable, as he suggested. That will prevent the cell editor from appearing when the cell is double-clicked. Then, in your context menu handler, if they select Rename, enable editing for the column and start the cell editor. You can either immediately set the column to be not editable again, or you can listen for a "dataEdited" event on the table object and set the column to not editable there. (I don't currently see any requirement that the cell remain editable while you are editing -- nothing checks for it -- but it's kind of strange to be editing while the cell is not editable and it's possible that a future change would cause some problems. It's therefore a more straight-forward solution to prevent editing immediately after calling startEditing(), but is slightly more future-proof to prevent editing at the moment that editing is complete. Your choice. I think I'd go with the straight-forward solution, and risk the very (very, very, very) slight chance that a code change later breaks it.

Cheers,

Derrell


------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

Jörg Sawatzki
Hey Derrell,

thanks once again. Actually, rsantiagopaz's solution was already in my
mind when I posted my question here but at that time I thought that this
a quick and dirty hack that I shouldn't think about :)

Anyway...Can I somehow prevent the focus indicator to jump down to the
next line? Usually users only want to rename one file at a time and not
everything in the directory - so that would be a bit irritating....

e.preventDefault() on the dataEdited event is not the solution :)

Cheers

Jörg

Am Mittwoch, den 12.05.2010, 16:43 -0400 schrieb Derrell Lipman:

> On Wed, May 12, 2010 at 15:56, Jörg Sawatzki <[hidden email]>
> wrote:
>         Hey guys,
>        
>         thanks for your help so far. Gonna try both solution and if
>         nothing
>         suits my needs I will just ask the user for a new name in a
>         popup :)
>
> Jörg, rsantiagopaz's suggestion is better than mine. Set each column
> to not be editable, as he suggested. That will prevent the cell editor
> from appearing when the cell is double-clicked. Then, in your context
> menu handler, if they select Rename, enable editing for the column and
> start the cell editor. You can either immediately set the column to be
> not editable again, or you can listen for a "dataEdited" event on the
> table object and set the column to not editable there. (I don't
> currently see any requirement that the cell remain editable while you
> are editing -- nothing checks for it -- but it's kind of strange to be
> editing while the cell is not editable and it's possible that a future
> change would cause some problems. It's therefore a more
> straight-forward solution to prevent editing immediately after calling
> startEditing(), but is slightly more future-proof to prevent editing
> at the moment that editing is complete. Your choice. I think I'd go
> with the straight-forward solution, and risk the very (very, very,
> very) slight chance that a code change later breaks it.
>
> Cheers,
>
> Derrell
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

Derrell Lipman
On Thu, May 13, 2010 at 15:50, Jörg Sawatzki <[hidden email]> wrote:
Hey Derrell,

thanks once again. Actually, rsantiagopaz's solution was already in my
mind when I posted my question here but at that time I thought that this
a quick and dirty hack that I shouldn't think about :)

Anyway...Can I somehow prevent the focus indicator to jump down to the
next line? Usually users only want to rename one file at a time and not
everything in the directory - so that would be a bit irritating....

I believe the jump to the next line is a result of Enter being caught by Table's _onKeyPress method, and thererfore it should be happening early enough that you can listen to the table's "dataEdited" method and reset the focused cell. Try this:

table.addListener("dataEdited", function(e)
  {
    var editData = e.getData();
    table.setFocusedCell(editData.col, editData.row, true);
  });

Cheers,

Derrell


------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to avoid the cell editor on a double click?

rsantiagopaz
In reply to this post by Jörg Sawatzki
"Can I somehow prevent the focus indicator to jump down to the
next line?"


Try with this class instead Qooxdoo original class
(change "pediatras.controles.table.Table" with your correct namespace)



qx.Class.define("pediatras.controles.table.Table",
{
        extend : qx.ui.table.Table,
        construct : function (tableModel, custom)
        {
                this.base(arguments, tableModel, custom);
               

        },
        members :
        {

               
                _onKeyPress : function(evt)
    {
      if (!this.getEnabled()) {
        return;
      }

      // No editing mode
      var oldFocusedRow = this.__focusedRow;
      var consumed = true;

      // Handle keys that are independent from the modifiers
      var identifier = evt.getKeyIdentifier();

      if (this.isEditing())
      {
        // Editing mode
        if (evt.getModifiers() == 0)
        {
          switch(identifier)
          {
            case "Enter":
              this.stopEditing();
              //var oldFocusedCol = this.__focusedCol;
              //this.moveFocusedCell(1, 0);

              //if (this.__focusedCol != oldFocusedCol) {
                //consumed = this.startEditing();
              //}

              break;

            case "Escape":
              this.cancelEditing();
              this.focus();
              break;

            default:
              consumed = false;
              break;
          }
        }
        return
      }
      else
      {
        // No editing mode
        if (evt.isCtrlPressed())
        {
          // Handle keys that depend on modifiers
          consumed = true;

          switch(identifier)
          {
            case "A": // Ctrl + A
              var rowCount = this.getTableModel().getRowCount();

              if (rowCount > 0) {
                this.getSelectionModel().setSelectionInterval(0, rowCount - 1);
              }

              break;

            default:
              consumed = false;
              break;
          }
        }
        else
        {
          // Handle keys that are independent from the modifiers
          switch(identifier)
          {
            case "Space":
              this.__selectionManager.handleSelectKeyDown(this.__focusedRow, evt);
              break;

            case "F2":
            case "Enter":
              consumed = this.startEditing();
              break;

            case "Home":
              this.setFocusedCell(this.__focusedCol, 0, true);
              break;

            case "End":
              var rowCount = this.getTableModel().getRowCount();
              this.setFocusedCell(this.__focusedCol, rowCount - 1, true);
              break;

            case "Left":
              this.moveFocusedCell(-1, 0);
              break;

            case "Right":
              this.moveFocusedCell(1, 0);
              break;

            case "Up":
              this.moveFocusedCell(0, -1);
              break;

            case "Down":
              this.moveFocusedCell(0, 1);
              break;

            case "PageUp":
            case "PageDown":
              var scroller = this.getPaneScroller(0);
              var pane = scroller.getTablePane();
              var rowCount = pane.getVisibleRowCount() - 1;
              var rowHeight = this.getRowHeight();
              var direction = (identifier == "PageUp") ? -1 : 1;
              scroller.setScrollY(scroller.getScrollY() + direction * rowCount * rowHeight);
              this.moveFocusedCell(0, direction * rowCount);
              break;

            default:
              consumed = false;
          }
        }
      }

      if (oldFocusedRow != this.__focusedRow &&
          this.getRowFocusChangeModifiesSelection())
      {
        // The focus moved -> Let the selection manager handle this event
        this.__selectionManager.handleMoveKeyDown(this.__focusedRow, evt);
      }

      if (consumed)
      {
        evt.preventDefault();
        evt.stopPropagation();
      }
    }
        }
});