Author Topic: Is there an option to decide arrow key semantics during edit  (Read 654 times)

Mikael Andersen

  • Pro OEM
  • Newbie
  • *
  • Posts: 9
    • View Profile
Both Java's JTable and Excel, has semantically identical behavior when it comes to cell-editing and behavior of arrow keys, which differs from PQGrid.
In JTable/Excel, there is kind of two different edit-modes.
1. In which you start typing directly overriding the existing value
2. Init editing through double-click or typically F2 key

In first case, any arrow key pressed, commits the edit and moves cell selection in the pressed keys direction.
In the second case, the arrow keys provides no escape mechanism, but only provide caret position control

PQGrid by default uses a mixed of these approaches, where arrow keys UP/DOWN always provides this commit/move operation, while LEFT/RIGHT always provides caret control.
Is there some setting for PQGrid which affects this behavior or would I have to manually implement this or is there already some working example, still using custom code?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6552
    • View Profile
Re: Is there an option to decide arrow key semantics during edit
« Reply #1 on: June 04, 2026, 05:55:53 pm »
That is an interesting requirement.

You are right: pqGrid doesn't differentiate how the editor is initiated, and there is no example for this specific dual-mode behavior currently.

I am looking into a customizable solution for this. If it works cleanly, I will provide you with the custom code shortly; otherwise, we will look into implementing this natively in an upcoming version of the grid.

Mikael Andersen

  • Pro OEM
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Is there an option to decide arrow key semantics during edit
« Reply #2 on: June 04, 2026, 07:51:21 pm »
Brilliant - looking forward to seeing your custom implementation :)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6552
    • View Profile
Re: Is there an option to decide arrow key semantics during edit
« Reply #3 on: June 05, 2026, 03:14:54 pm »
Please check this example:

https://paramquery.com/pro/demos/key_navigation

Code: [Select]
  editorKeyDown(evt, ui) {
      if (globalEditByPress) {
          let c1, r1;
          //check left and right key with key names
          if (evt.key == "ArrowRight") {
              c1 = this.getNextVisibleCI(ui.colIndx + 1);
              r1 = ui.rowIndxPage
          } else if (evt.key == 'ArrowLeft') {
              c1 = this.getPrevVisibleCI(ui.colIndx - 1);
              r1 = ui.rowIndxPage
          } else if (evt.key == 'ArrowUp') {
              r1 = this.getPrevVisibleRIP(ui.rowIndx);
              c1 = ui.colIndx
          } else if (evt.key == 'ArrowDown') {
              r1 = this.getNextVisibleRIP(ui.rowIndx);
              c1 = ui.colIndx
          }
          if (r1 != null && c1 != null) {
              this.focus({
                  rowIndxPage: r1,
                  colIndx: c1
              });
              this.Range({
                  r1,
                  c1
              }).select();
              return false; //to prevent default handing of keys b
          }
      }
  },
« Last Edit: June 05, 2026, 06:12:20 pm by paramvir »

Mikael Andersen

  • Pro OEM
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Is there an option to decide arrow key semantics during edit
« Reply #4 on: June 05, 2026, 04:28:05 pm »
Thx, behavior in demo seems consistent with the before mentioned tools. Amazing. Thank you :)