Skip to content

Highlight API: Hit testing? #54

Closed
Closed

Description

It may be useful to be able to listen for events like click on these ranges. Is this something you've already considered?

Activity

  1. frivoal commented on Jun 28, 2019

    @frivoal

    That sounds useful, but shouldn't we aim to solve it for all css-pseudo elements rather than special-case it for highlight pseudos?

  2. sanketj commented on Aug 30, 2019

    @sanketj
    Contributor

    Hi Theresa O’Connor (@hober) , thanks for your feedback here! We have put together an explainer to address this scenario: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/highlight/events-explainer.md. It proposes a new type of pointer event for highlighted ranges.

    We would appreciate if you could go through it and provide any additional feedback that you may have.

  3. added
    HighlightEvents
    and removed on Sep 11, 2019
  4. hober commented on Sep 16, 2019

    @hober
    Author

    Sanket Joshi (@sanketj) This looks pretty good, thanks. I'm concerned about this being only available on Pointer Events, though. Regular old mouse events should ideally be supported here, too.

  5. sanketj commented on Sep 16, 2019

    @sanketj
    Contributor

    Theresa O’Connor (@hober) HighlightRangeGroup would support all MouseEvent types, and all PointerEvent types except gotpointercapture/lostpointercapture: (https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/highlight/events-explainer.md#event-types). The example in the explainer - repasted below - shows how the API may be used with click:

            const findHighlights = new HighlightRangeGroup()
            CSS.highlights.set("find-highlights", findHighlights)
    
            // simulated find result for the word "highlight"
            const text = document.getElementById("content").firstChild
            const range = new Range();
            range.setStart(text, text.length - "highlight".length)
            range.setEnd(text, text.length)
            findHighlights.add(range)
    
            // on click of a range in the find-highlights group, move selection
            // to coincide with the result
            findHighlights.addEventListener("click", e => {
                const range = e.range
                const selection = getSelection()
                selection.removeAllRanges()
                selection.addRange(range)
            })
    
  6. hober commented on Sep 16, 2019

    @hober
    Author

    Oh, okay. Yeah, that seems reasonable to me.

  7. sanketj commented on Sep 18, 2019

    @sanketj
    Contributor

    Thanks Theresa O’Connor (@hober) . I guess I'll close this issue out, and we can open up new issues on specific details based on our F2F discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

HighlightEvents

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions