默认的 Delphi 10.4.2 TEdgeBrowser 界面目前只是原始发布的 WebView2。但是,似乎要在非白色背景上实现无闪烁负载,我们需要使用ICoreWebView2Controller2设置背景颜色。如何从 Delphi 访问它(以向后兼容的方式)?我曾尝试从 Microsoft 更新的 WebView2 nuget 包中导入 .tlb,但是 Delphi 给出了 OLE 错误,因此我找不到使用新功能生成 Delphi WebView2 界面的方法。
我正在使用NSTextView来显示长搜索的结果,其中添加了行,因为它们是由后台线程使用的
[self performSelectorOnMainThread: @selector(addMatch:)
withObject:options waitUntilDone:TRUE];
Run Code Online (Sandbox Code Playgroud)
作为我的更新程序
-(void)addMatch:(NSDictionary*)options{
...
NSTextStorage* store = [textView textStorage];
[store beginEditing];
[store appendAttributedString:text];
...
[store endEditing];
}
Run Code Online (Sandbox Code Playgroud)
这样可以正常工作,直到用户在更新时滚动匹配,此时会出现异常
- [NSLayoutManager _fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:]***在textStorage编辑时尝试布局.在textStorage编辑时使layoutManager进行布局是无效的(即textStorage已经发送了一个没有匹配的endEditing的beginEditing消息.)
在布局调用中:
0 CoreFoundation 0x00007fff92ea364c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8acd16de objc_exception_throw + 43
2 CoreFoundation 0x00007fff92ea34fd +[NSException raise:format:] + 205
3 UIFoundation 0x00007fff8fe4fbc1 -[NSLayoutManager(NSPrivate) _fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] + 641
4 UIFoundation 0x00007fff8fe5970c _NSFastFillAllLayoutHolesForGlyphRange + 1493
5 UIFoundation 0x00007fff8fda8821 -[NSLayoutManager lineFragmentRectForGlyphAtIndex:effectiveRange:] + 39
6 AppKit 0x00007fff8ef3cb02 -[NSTextView _extendedGlyphRangeForRange:maxGlyphIndex:drawingToScreen:] + 478
7 AppKit 0x00007fff8ef3ba97 -[NSTextView drawRect:] + 1832 …
Run Code Online (Sandbox Code Playgroud)