+2005-02-06 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed <rdar://problem/3993722> need oncut and onpaste handlers implemented for <textarea> (needed for widgets)
+
+ * kwq/KWQTextArea.mm:
+ (-[KWQTextAreaTextView dispatchHTMLEvent:]): Added.
+ (-[KWQTextAreaTextView cut:]): Dispatch "before cut" and "cut" events.
+ (-[KWQTextAreaTextView copy:]): Dispatch "before copy" and "copy" events.
+ (-[KWQTextAreaTextView paste:]): Dispatch "before paste" and "paste" events.
+ (-[KWQTextAreaTextView pasteAsPlainText:]): Ditto.
+ (-[KWQTextAreaTextView pasteAsRichText:]): Ditto.
+
2005-02-06 Darin Adler <darin@apple.com>
Reviewed by Maciej.
#import "KWQKHTMLPart.h"
#import "KWQNSViewExtras.h"
#import "KWQTextEdit.h"
+#import "render_replaced.h"
#import "WebCoreBridge.h"
+using DOM::EventImpl;
+using DOM::NodeImpl;
+using khtml::RenderWidget;
+
/*
This widget is used to implement the <TEXTAREA> element.
QTextEdit *widget;
BOOL disabled;
BOOL editableIfEnabled;
+ BOOL inCut;
}
- (void)setWidget:(QTextEdit *)widget;
[[self textStorage] setForegroundColor:color];
}
+// Could get fancy and send this to QTextEdit, then RenderTextArea, but there's really no harm
+// in doing this directly right here. Could refactor some day if you disagree.
+
+// FIXME: This does not yet implement the feature of canceling the operation, or the necessary
+// support to implement the clipboard operations entirely in JavaScript.
+- (void)dispatchHTMLEvent:(EventImpl::EventId)eventID
+{
+ if (widget) {
+ const RenderWidget *rw = static_cast<const RenderWidget *>(widget->eventFilterObject());
+ if (rw) {
+ NodeImpl *node = rw->element();
+ if (node) {
+ node->dispatchHTMLEvent(eventID, false, false);
+ }
+ }
+ }
+}
+
+- (void)cut:(id)sender
+{
+ inCut = YES;
+ [self dispatchHTMLEvent:EventImpl::BEFORECUT_EVENT];
+ [super cut:sender];
+ [self dispatchHTMLEvent:EventImpl::CUT_EVENT];
+ inCut = NO;
+}
+
+- (void)copy:(id)sender
+{
+ if (!inCut)
+ [self dispatchHTMLEvent:EventImpl::BEFORECOPY_EVENT];
+ [super copy:sender];
+ if (!inCut)
+ [self dispatchHTMLEvent:EventImpl::COPY_EVENT];
+}
+
+- (void)paste:(id)sender
+{
+ [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+ [super paste:sender];
+ [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
+- (void)pasteAsPlainText:(id)sender
+{
+ [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+ [super pasteAsPlainText:sender];
+ [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
+- (void)pasteAsRichText:(id)sender
+{
+ [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+ [super pasteAsRichText:sender];
+ [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+}
+
@end
@implementation NSView (KWQTextArea)