Reviewed by Dave Hyatt.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jan 2005 19:14:35 +0000 (19:14 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 31 Jan 2005 19:14:35 +0000 (19:14 +0000)
        - fixed <rdar://problem/3949203> cannot tab to, within, or out of the RSS sidebar

        * kwq/KWQSlider.mm:
        (-[KWQSlider becomeFirstResponder]):
        (-[KWQSlider resignFirstResponder]):
        (-[KWQSlider nextKeyView]):
        (-[KWQSlider previousKeyView]):
        (-[KWQSlider canBecomeKeyView]):
        (-[KWQSlider nextValidKeyView]):
        (-[KWQSlider previousValidKeyView]):
        Copied these methods from KWQButton. The lack of special handling for first-responder-ness
        here was causing the focus to get "stuck" on the RSS page's slider widget. Added FIXME
        about how it would be nice to share more of this code rather than replicating it in each
        KWQ widget subclass.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8484 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQSlider.mm

index 55e0f24..9ec6d76 100644 (file)
@@ -1,3 +1,22 @@
+2005-01-31  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Dave Hyatt.
+        
+        - fixed <rdar://problem/3949203> cannot tab to, within, or out of the RSS sidebar
+
+        * kwq/KWQSlider.mm:
+        (-[KWQSlider becomeFirstResponder]):
+        (-[KWQSlider resignFirstResponder]):
+        (-[KWQSlider nextKeyView]):
+        (-[KWQSlider previousKeyView]):
+        (-[KWQSlider canBecomeKeyView]):
+        (-[KWQSlider nextValidKeyView]):
+        (-[KWQSlider previousValidKeyView]):
+        Copied these methods from KWQButton. The lack of special handling for first-responder-ness
+        here was causing the focus to get "stuck" on the RSS page's slider widget. Added FIXME
+        about how it would be nice to share more of this code rather than replicating it in each
+        KWQ widget subclass.
+
 2005-01-31  Darin Adler  <darin@apple.com>
 
         Reviewed by Harrison.
index 8a3c0db..e929801 100644 (file)
 
 #import "KWQButton.h"
 #import "KWQExceptions.h"
+#import "KWQKHTMLPart.h"
+#import "KWQNSViewExtras.h"
 #import "KWQView.h"
 
 @interface KWQSlider : NSSlider <KWQWidgetHolder>
 {
     QSlider* slider;
+    BOOL inNextValidKeyView;
 }
 
 - (id)initWithQSlider:(QSlider*)s;
     return slider;
 }
 
+// FIXME: All the firstResponder and keyView code here is replicated in KWQButton and
+// other KWQ classes. We should find a way to share this code.
+- (BOOL)becomeFirstResponder
+{
+    BOOL become = [super becomeFirstResponder];
+    if (become && slider) {
+        if (!KWQKHTMLPart::currentEventIsMouseDownInWidget(slider)) {
+            [self _KWQ_scrollFrameToVisible];
+        }
+        QFocusEvent event(QEvent::FocusIn);
+        const_cast<QObject *>(slider->eventFilterObject())->eventFilter(slider, &event);
+    }
+    return become;
+}
+
+- (BOOL)resignFirstResponder
+{
+    BOOL resign = [super resignFirstResponder];
+    if (resign && slider) {
+        QFocusEvent event(QEvent::FocusOut);
+        const_cast<QObject *>(slider->eventFilterObject())->eventFilter(slider, &event);
+    }
+    return resign;
+}
+
+-(NSView *)nextKeyView
+{
+    NSView *view = nil;
+    if (slider && inNextValidKeyView) {
+        // resign so we send a blur before setting focus on
+        // the next widget, otherwise the blur for this
+        // widget will remove focus from the widget after
+        // we tab to it
+        [self resignFirstResponder];
+        view = KWQKHTMLPart::nextKeyViewForWidget(slider, KWQSelectingNext);
+    }
+    else { 
+        view = [super nextKeyView];
+    }
+    return view;
+}
+
+-(NSView *)previousKeyView
+{
+    NSView *view = nil;
+    if (slider && inNextValidKeyView) {
+        // resign so we send a blur before setting focus on
+        // the next widget, otherwise the blur for this
+        // widget will remove focus from the widget after
+        // we tab to it
+        [self resignFirstResponder];
+        view = KWQKHTMLPart::nextKeyViewForWidget(slider, KWQSelectingPrevious);
+    }
+    else { 
+        view = [super previousKeyView];
+    }
+    return view;
+}
+
+- (BOOL)canBecomeKeyView
+{
+    // Simplified method from NSView; overridden to replace NSView's way of checking
+    // for full keyboard access with ours.
+    if (slider && !KWQKHTMLPart::partForWidget(slider)->tabsToAllControls()) {
+        return NO;
+    }
+    return ([self window] != nil) && ![self isHiddenOrHasHiddenAncestor] && [self acceptsFirstResponder];
+}
+
+-(NSView *)nextValidKeyView
+{
+    inNextValidKeyView = YES;
+    NSView *view = [super nextValidKeyView];
+    inNextValidKeyView = NO;
+    return view;
+}
+
+-(NSView *)previousValidKeyView
+{
+    inNextValidKeyView = YES;
+    NSView *view = [super previousValidKeyView];
+    inNextValidKeyView = NO;
+    return view;
+}
+
 @end
 
 enum {