Can't scroll on touch screens
The grid doesn't seem to respond to scrolling events on touch screens. I can tap without any issues, but scrolling doesn't seem to work. This in turn doesn't also allow resizing or moving columns. The grid doesn't seem to respond to touch events.
This is a bit of an urgent issue, as we are currently in the process of moving our entire application to Hypergrid. We would like to know if it's just a matter of configuration or if Hypergrid doesn't support touch screens, and if not, if it's possible to request this feature.
Touch screen support was never completed. I will look into this today and assess the amount of work involved and I'll post here my findings and when I think I could get it done.
(Of course, contributions are always welcome! Is there any chance you have the bandwidth to contribute a solution to this issue?)
@joneit Of course! I'd be more than happy to contribute a solution (or at least try). If you could just give me a heads up as to where to start, that would be great (if not that's fine too). Also, is there a way to contact you in case I have any questions?
@AmirF27 That would be great!
Look in ./src/lib/Canvas.js at the way "click" events are implemented. We need to implement Touch events similarly (see also Using Touch Events), including how they are consumed.
How Hypergrid sets up events
The way events are handled in Hypergrid is a little heavy handed:
- In
./src/Hypergird/index.js, for each grid instance (let's call itgrid) the constructor (Hypergrid.prototype.initialize) callsthis.initCanvasto instantiate its ownCanvasobject (grid.canvas) - In
./src/lib/Canvas.js, the constructor (Canvas.prototype.initialize)- Creates the
<canvas>element (this.canvas===grid.canvas.canvas) - Calls its own
this.addEventListenerto set up listeners on the actual for each mouse event type (e.g.,click) to be handled by specificthis.fin______class methods (e.g.,this.finclick) - The
this.fin______handlers calldispatchNewMouseKeysEventto rethrow the DOM event as afin-canvas-custom event (e.g.,fin-canvas-click) (dispatchNewMouseKeysEventmay or may not suffice for touch events; if not, add a new method)
- Creates the
grid.initCanvasthen callsthis.delegateCanvasEvents(in./src/Hypergrid/events.js) for each suchfin-canvas-event, which callsthis.addInternalEventListenerwith a handler (an anonymous function) which:- May include state maintenance logic specific to the event
- Calls
this.delegate______method (e.g.,this.delegateClick)- These methods merely call a
this.behavior.on________method (e.g.,this.behavior.onClick)
- These methods merely call a
- Calls
this.fireSynthetic_______Event(e.g.,this.fireSyntheticClickEvent)- These methods all call
dispatchGridEventwith specific event details - This is what calls any listeners the application developer may have added to the grid (via
grid.addEventListener) - Note that besides the primitive synthetic events for
click,mousedown, etc., there are also semantic synthetic events called from the feature chain (e.g.,fireSyntheticEditorKeyPressEvent)
- These methods all call
Setting up dev environment
-
We will be doing some dev work on the Hypergrid core repo, so step 1 is to clone it:
cd ~ mkdir repos cd repos git clone https://github.com/fin-hypergrid/core fin-hypergridThis creates a new directory
~/repos/fin-hypergridcontaining the clone of thecorerepo. (It is currently not necessary to runnpm buildoncoreunless you are changing the built-in stylesheet or images. Important: You should however, runnpm lintbefore committing your changes.) -
I usually develop with the "dev testbench" (
build/demo/index.html), so let's clone that too:git clone https://github.com/fin-hypergrid/buildThis creates a new directory
~/repos/build. -
Before running
npm install, which would install[email protected](among other items) from the npm registry, you need to point that dependency to your localcoreclone:cd build npm install ../fin-hypergridThis does two things:
- Installs the
fin-hypergriddependency as a simple symlink instead of a folder innode_modules/fin-hypergrid - Changes package.json
'sfin-hypergirddependency from=3.2.0tofile:../fin-hypergrid`.Important: Do not commit this change! You will want to change it some new version number such as
=3.4.0or whatever; we will decide when the time comes which version. (YourbuildPR is in addition to yourcorePR; it adds listeners to./testbench/events.jsto demonstrate your new events in the testbench.)
- Installs the
-
Now run the rest of the install (this will ignore the
fin-hypergirddependency because it is already installed):npm install -
Between editing the core files and refreshing the browser, you must rebuild the test bench:
sh bundle-demo.shNOTE: This actually does two builds: The regular file with source map; and the min file without source map. In practice, I just do the first of the two (
browserify testbench/index.js -do demo/build/testbench.js) because the min build is slow and is not even used in testing.NOTE: This just builds
testbench.js. To buildfin-hypergrid.js, used by the other demos, runsh core-bundle.sh. -
To test on a touch device
- From a new console session, issue the following commands from the
~/repos/builddirectory:npm install --global http-server # first time only http-server demo - From your device, go to browser and enter the URL displayed in the console:
192.168.x.y:8080
- From a new console session, issue the following commands from the
User Interaction
Now we get to how exactly are we going to define touches.
Issues
There are several problems here:
- Scrolling doesn't work
- There's no way to make multiple selections (usually accomplished with click + drag)
- There's no way to invoke a cell editor.
Proposed UI solution
I believe you are only interested in the first item above.
For scrolling, what would feel natural to me is a single touch (i.e., one finger) + drag.
My contact info
If you want to ask me questions privately, my email address is on my user page.
@joneit Thank you for the explanations! I will get started as soon as I'm able. Should I fork the repository or can I clone this one and work directly on it?
Regarding the issues, my team and I are indeed only interested in the first item for the moment. Should I try to work on the other two or can I focus only on the first item for now?
Hi @joneit. I've got a couple questions regarding this feature. I've sent you an email. Please let me know when you see it or if you see this comment. If there is anyone else I can ask it would be great too.
Hi @joneit. I've sent you an email regarding opening a pull request for this issue. I'm ready to open a pull request. Would you be able to look at it?
@joneit & @AmirF27 I'd love to see this merged in this repo & added to perspectiveJS grid eventually to get touch screen support for the vscode ext. data viz tools I've built with your grid: https://github.com/RandomFractals/vscode-data-preview
any ETA on this PR being approved and released?