我正在使用CKEditor在Cocoa应用程序中集成HTML。
到目前为止,除了一件事外,它的工作原理是:如果我在应用程序中的任何地方打开一个NSColorPanel并选择一个颜色,那么CKEditor中选择的颜色就会自动发生变化!
怎么会发生这种事?NSColorPanel ( Cocoa窗口)如何与CKEditor (一个HTML!)通信?最后,我怎样才能防止这种行为?
码
我是通过子类WebView和重写initWithFrame:frameName:groupName来加载initWithFrame:frameName:groupName的。
- (id) initWithFrame:(NSRect)frame frameName:(NSString *)frameName groupName:(NSString *)groupName {
if (self = [super initWithFrame:frame frameName:frameName groupName:groupName]) {
NSURL *baseURL = [[NSBundle bundleForClass:self.class] URLForResource:@"ckeditor" withExtension:nil];
[self.mainFrame loadHTMLString:kCKEditorTemplate baseURL:baseURL];
}
return self;
}NSColorPanel是这样打开的:
- (IBAction)menuColor:(id)sender {
[[NSColorPanel sharedColorPanel] orderFront:self];
}我到目前为止发现了什么,
changeColor:此方法由NSColorPanel发送方调用,其行为类似于NSTextView中的changeColor:方法。
但是,我尝试过重写changeColor:,并且没有调用它。
<font>元素而不是<span>元素(就像通过工具栏更改文本颜色时一样)。这意味着选择的颜色不会被传统的方法改变(也许是纸板?)。发布于 2012-09-22 15:02:10
我没有任何关于可可和网络视图的经验,我只能尝试在IE activeX控件方面考虑这个问题,所以我可能错了。
话虽如此:
如果插入的代码使用的是字体而不是span,那么我认为它不是CKEditor,而是Webkit --它正在插入该代码。
您可以尝试加载一个页面,而不是一个CKEditor实例,它只有一个内容可编辑的div,然后执行相同的测试,以验证它是否在webkit中完成:
<div contentEditable=true>this is editable, select some text and open the nscolorpanel</div>https://stackoverflow.com/questions/12543320
复制相似问题