如何在WebView中突出显示搜索结果,如Safari和NSTextView showFindIndicatorForRange: [英] How to I highlight search results in a webview like Safari and NSTextView showFindIndicatorForRange:
问题描述
在Safari中,在OSX上的NSTextView中,搜索结果可以突出显示一个明亮的黄色框,有一些动画的流行。
答案(截至2013年5月)似乎是你必须手动突出显示在webview中的查找结果(ref:实现查找菜单项(如Safari?)线程从2011年),虽然它是一个长期规划的webkit功能。
我将列出我在研究此链接时发现的链接。 >
- 有 HighlightedWebView ,但在写入的时间似乎插入
< span>
以突出显示搜索字词。 - 我找不到答案关于如何使用Core Animation模仿此效果:
- 关于cocoa-dev的核心动画 - Safari查找效果有解决方案的概述,但没有代码
- Mimicking showFindIndicatorForRange with CALayer 这里SO没有答案
- 在WebView和NSTextFinder(标准查找栏界面)上:
- 如何让NSTextFinder显示在这里SO是相关的,但它似乎并不是关于这个确切的问题
- NSTextFinder参考(查找栏的文本视图支持部分)建议它可以绘制任何NSView / NSScrollView的黄色查找指示器背景边框,如果它支持NSTextFinderClient其中WebView不参考: [1] , [2] )。
- WebView查找面板/ bar implementation,位于 cocoa-dev < a>是最近的(2013-04)主题,其中包含可能解决方案的概述。
In Safari, and in an NSTextView on OSX, search results can be highlighted with a bright yellow box that has a little animated pop. Is there any way to do this in a webview without coding it all myself?
The answer (as of 2013-05) seems to be that you have to highlight the find results in the webview manually (ref: "Implementing a Find menu item like Safari?" thread from 2011), although it's a long-planned webkit feature.
I'll list the links I found while researching this.
- There's HighlightedWebView but at the time of writing it appears to insert
<span>
s to highlight the search terms. - I couldn't find an answer on how to mimic this effect with Core Animation:
- Core animation - Safari Find effect on cocoa-dev has an overview of the solution, but no code
- Mimicking showFindIndicatorForRange with CALayer here on SO has no answers
- On WebView and NSTextFinder (the standard find bar interface):
- How do I get NSTextFinder to show up here on SO is related, but it doesn't seem it's about this exact problem.
- NSTextFinder reference (the "Text View Support for the Find Bar" section) suggests it can draw "the yellow find indicator background bezel" for any NSView/NSScrollView if it supports NSTextFinderClient (which WebView does not - ref.: [1], [2]).
- "WebView find panel/bar implementation" on cocoa-dev is the most recent (2013-04) thread on this and it contains an overview of the possible solution.
这篇关于如何在WebView中突出显示搜索结果,如Safari和NSTextView showFindIndicatorForRange:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!