Skip to content

Hypergrid v2.1.13

Choose a tag to compare

@joneit joneit released this 12 Jun 17:55
· 172 commits to master since this release
abfca3a

See also

In addition to the release notes below, please refer also to:

This patch release v2.1.13 supersedes v2.1.10

  • Reflects PRs #722 (v2.1.11) + #727 (v2.1.12) + #728 (v2.1.13)
  • Note that there were no releases v2.1.1, v2.1.9, v2.1.11, or 2.1.12

Published to npm

This release has been published as a module to the npm registry.

Pre-bundled build file

A bundled build of this release is available on the CDN.

Synopsis

  1. Support for non-US keyboard layouts (resolves Issues #621 and #623; supersedes PRs #622 and #626)
  2. Scrolling speed (resolves Issue #290; supersedes PR #620)
  3. Fix fin-button-pressed event handler in TestBench (demo)
  4. Fix Renderer.prototype.findCell
  5. Add config.clickRect write-only prop for cell renderer
  6. Draw frame around last row or column selection
  7. Add "collapse cell selections" testbench feature
  8. Allow auto-row and -column selection without cell selection
  9. Improve Textfield cell editor
  10. Improve cell editor base class (CellEditor.js)
  11. Fix and enhance testbench's Time cell editor
  12. New: demo/formatter-workbench

1. Support for non-US keyboard layouts

Hypergrid until now has depended on the long-deprecated KeyboardEvent#keyCode to infer the printable character. This assumes a particular keyboard layout and mapping of keyCode to physical keys.

Issue #621: Characters are wrongly mapped for non-US keyboards

This PR resolves this issue (Issue #621). The logic no longer depends on keyCode although the legacy logic is still in place and the legacy value is still available in event.legacyChar:

  • grid.canvas.getKeyChar(keyboardEvent) now returns keyboardEvent.key for "printable" chars, include the space char.
  • printable chars are discriminated from non-printable characters when key.length === 1
  • for the event e passed to events fin-keydown, fin-keyup, fin-editor-keydown, fin-editor-keypress, and fin-editor-keyup:
  • e.char is still set as before by grid.canvas.getKeyChar(e) but now contains the new result
  • e.legacyChar (new prop) is the old e.char value, when available (depends on keyCode still working and charMap coverage)
  • for non-printable chars (e.legacyChar.length > 1), e.char === e.legacyChar (still)

There are two breaking changes:

  1. The space bar previously returned e.char === 'SPACE' and therefore was considered a non-printable char. It is now considered a printable char, and e.char === ' ' instead.
  2. On the Mac, option (aka meta) + printable char generally returns generates some exotic printable char. Like non-US keyboard characters, these were previously lost. Now however e.char will contain the exotic char while e.legacyChar will contain the old value (the regular character as if the meta key was not down).

Issue #623: Space key does not open cell editor

The first breaking change above has the side-effect of also resolving #623: Space key does not open cell editor

2. Scrolling speed (Issue #290)

Added two new properties which are multipliers for the mouse wheel:

  • wheelHFactor: 0.02 - multiplier for horizontal mouse wheel movement, applied to values of WheelEvent#deltaX (received by the horizontal scrollbar's listener).
  • wheelVFactor: 0.05 - multiplier for vertical mouse wheel movement, applied to values of WheelEvent#deltaY (received by the vertical scrollbar's listener).

Caveat

Wheel granularity depends on the OS, the input device, and possibly the browser. Any setting you choose will work differently in different environments. If you don't know the user's environment, it is probably best to give users control of this setting so they can fine tune it themselves.

Default values

The particular default values shown above are a compromise. These settings seem to work well on the MacBook Pro trackpad. They also seem to work acceptably (though differently) with a mouse wheel on both Mac OS and Windows.

Be aware however that the trackpad scrolling speed can be adjusted by the Mac user at the OS level (System Preferences -> Accessibility -> Mouse & Trackpad -> Trackpad Options… -> Scrolling speed). Mouse wheel scrolling speed is also adjustable ( yada yada -> Mouse Options… -> Scrolling speed; or on Windows search for "Change mouse wheel settings" in the Start menu).

This setting feels good on trackpad (2-finger drag). It's much slower than it was, but the way it was was way to coarse and fast, scrolling hundreds of rows in a flash.

With this setting, a mouse connected to a Mac, the wheel requires 5 click-stops to scroll 1 row; the same mouse connected to Windows scrolls 5 rows per click-stop. (However, I may have changed the default settings on my machines; not sure.)

On Windows, the original vertical multiplier setting (i.e., 1.0) scrolled 100 grid rows on a single mouse wheel click-stop; the new default (0.05) scrolls 5 rows per click-stop. It stands to reason therefore that a setting of 0.01 will scroll 1:1 (1 row per 1 click-stop).

Hint

You can tell if the user is using a trackpad by listening for any deltaX (since a simple mouse wheel is deltaY only); and what OS by checking user agent.

3. Fix fin-button-pressed event handler in TestBench (demo)

Fixed an issue that prevented the fin-button-pressed event from being fired when user clicks on a cell rendered by the Button cell renderer.

Also retired the following core code which supported this event:

  • grid.renderer.buttonCells object
  • config.buttonCells object (reference to grid.renderer.buttonCells
  • grid.renderer.isViewableButton(c, r) method
  • grid.isViewableButton(c, r) method (stub that calls the renderer version)

The above code, intended for internal use only, tracked and identified the set of visible cells rendered by the Button cell renderer so that clicking them could dispatch the fin-button-pressed event. That solution may have been left over from an early release that lacked general column properties (much less cell properties). In any case, it has been updated to simply check the cell's cell renderer name (event.properties.renderer === 'button').

4. Fix Renderer.prototype.findCell

  • Fixed a bug in Renderer.prototype.findCell where the cellEvent[] pool size was being miscalculated because it was not accounting for row number column and/or tree column (when present). Previously, when these columns were present the algorithm was failing to scan enough elements and was therefore missing targets in the last 1 or 2 columns.
  • Upgraded grid.renderer.getGridCellFromMousePoint to return the actual cellEvent from the pool (rather than a new one with the same coordinates) so that decorations added by the cell renderer are now available to mouse events, in particular the new clickRect property described below.

5. Add config.clickRect write-only prop for cell renderer

  • Using local cell coordinates, cell renderers can now at their option define a require('rectangular').Rectangle object (aka fin.Hypergrid.rectangular.Rectangle in the fin-hypergrid.js build) in the config.clickRect property, which the grid renderer then copies back onto the cellEvent object.
  • The fin-canvas-click event received from the canvas was previously always re-fired as the fin-click event. This event is now ignored however in the following cases:
    1. This event is now ignored if the mouse button was released when the mouse was no longer hovering over the cell it was over when the mouse button was depressed. Previously this event was always fired regardless because as it was is actually triggered by the browser on the entire <canvas> element, it fired even when the mouse was moved to another cell before releasing the mouse button.
    2. When and only when a clickRect subrect was defined on the event by the cell renderer: This event is now ignored if the mouse button was released when the mouse was no longer hovering over the clickRect (as it was when it was the mouse button was depressed).
  • Note that fin-mouseup and fin-double-click are unaffected by this change.

6. Draw frame around last row or column selection

  • Draw a frame around the visible portion of the last selection including row and column selections. Previously this feature only pertained to cell region selections. It now pertains to whatever was selected last. It is smart about deselecting.
  • Copy operation now copies the last selection (thing with the frame now drawn around it). Previously cell region selections always had priority, then row selections, then column selections.
  • Exception: The collapse cell region feature which collapses a cell region selection to a new row selection, continues to draw the frame around just the cells (the previous behavior). Note that this feature is only active when grid.properties.singleRowSelectionMode && !grid.properties.multipleSelections (which are the default settings).

7. Add "collapse cell selections" testbench feature

This feature has been imported from the "testbench" demo as a new option collapseCellSelections but it now defaults to false. You can turn it back on in the Dashboard -> Selections panel.

This feature basically causes row selections to move the last cell selection to the new row selection.

This feature only works in single row selection mode when selecting one row at a time (singleRowSelectionMode && !multipleSelections).

8. Allow auto-row and -column selection without cell selection

Previously, autoRowSelection and/or autoColumnSelection caused cell selection to select the row and/or column. This had the sometimes undesirable effect of selecting a cell along with the row and/or column. Prior to this release, this cell was always framed. This was because cells always had priority for framing although this is no longer the case (see item 6 above). Although this is no longer the case, the cell is still framed if the collapseCellSelections feature is active (see item 7 above); or if the row is subsequently deselected with a CTRL-click in the row handle cell.

With this change, rows and/or columns are now auto-selectable per autoRowSelection and/or autoColumnSelection even when cell selection is off (cellSelection = false). This configuration is preferable when you don't need cell selections and it also permits row deselection via CTRL-click anywhere in the row — rather requiring the click to be in the row handle cell.

9. Improve Textfield cell editor

  • Set input element font to cell's font on instantiation

10. Improve cell editor base class (CellEditor.js)

  • Prevent overlapping cell editor error effects which was distorting UI positioning
  • Add value param to getEditorValue and validateEditorValue methods for developer convenience. (Called with value this.input.value.)
  • Now handles error thrown from the call to localizer.invalid as an alternative to return value. (This aligns its functionality to that of localizer.parse.)

11. Fix and enhance testbench's Time cell editor

  • Add a keypress handler to accept typing "AM" or "PM" to toggle AM/PM (in addition to existing functionality requiring clicking on it). After toggling, the input is discarded (by calling preventDefault).
  • Reject (with error feedback effect) all other chars besides digits and colon.
  • Fix the hhmm localizer dependency:
    • Rename to clock12.
    • Remove tow-way interdependency on Time cell editor so localizer can stand alone.
    • Fix a bug by restoring missing NOON constant.

12. New: demo/formatter-workbench

  • This app helps learn about localizers and cell editors and can be used to develop them.
  • Includes examples.
  • Includes comprehensive documentation page with a short tutorial using the examples.

Defunct issues and PRs

All the above mentioned Issues (#621, #623, #290) and competing pull requests (#622, #626, and #620) have been closed.