Revision: 13044
          http://sourceforge.net/p/skim-app/code/13044
Author:   hofman
Date:     2022-07-21 09:37:03 +0000 (Thu, 21 Jul 2022)
Log Message:
-----------
take first responder into account for focus property

Modified Paths:
--------------
    trunk/SKColorSwatch.m

Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m       2022-07-20 17:31:11 UTC (rev 13043)
+++ trunk/SKColorSwatch.m       2022-07-21 09:37:03 UTC (rev 13044)
@@ -790,6 +790,15 @@
     return NSLocalizedString(@"colors", @"accessibility description");
 }
 
+- (NSArray *)accessibilitySelectedChildren {
+    if ([self selects] == NO)
+        return nil;
+    else if (selectedIndex == -1)
+        return [NSArray array];
+    else
+        return NSAccessibilityUnignoredChildren([itemViews 
subarrayWithRange:NSMakeRange(selectedIndex, 1)]);
+}
+
 - (id)accessibilityHitTest:(NSPoint)point {
     NSPoint localPoint = [self convertPointFromScreen:point];
     NSInteger i = [self colorIndexAtPoint:localPoint];
@@ -808,18 +817,25 @@
 }
 
 - (BOOL)isItemViewFocused:(SKColorSwatchItemView *)itemView {
-    return focusedIndex == (NSInteger)[itemViews indexOfObject:itemView];
+    return [[self window] firstResponder] == self && focusedIndex == 
(NSInteger)[itemViews indexOfObject:itemView];
 }
 
 - (void)itemView:(SKColorSwatchItemView *)itemView setFocused:(BOOL)focused {
-    NSUInteger anIndex = [itemViews indexOfObject:itemView];
-    if (focused && anIndex < [[self colors] count]) {
-        [[self window] makeFirstResponder:self];
-        focusedIndex = anIndex;
-        [self noteFocusRingMaskChanged];
+    if (focused) {
+        NSUInteger anIndex = [itemViews indexOfObject:itemView];
+        if (anIndex < [[self colors] count]) {
+            focusedIndex = anIndex;
+            [self noteFocusRingMaskChanged];
+        }
+        if ([[self window] firstResponder] != self)
+            [[self window] makeFirstResponder:self];
     }
 }
 
+- (BOOL)isItemViewSelected:(SKColorSwatchItemView *)itemView {
+    return selectedIndex !=-1 && selectedIndex == (NSInteger)[itemViews 
indexOfObject:itemView];
+}
+
 - (void)pressItemView:(SKColorSwatchItemView *)itemView {
     NSUInteger anIndex = [itemViews indexOfObject:itemView];
     if (anIndex < [[self colors] count])
@@ -1051,6 +1067,10 @@
     [(SKColorSwatch *)[self superview] itemView:self setFocused:flag];
 }
 
+- (BOOL)isAccessibilitySelected {
+    return [(SKColorSwatch *)[self superview] isItemViewSelected:self];
+}
+
 - (BOOL)accessibilityPerformPress {
     [(SKColorSwatch *)[self superview] pressItemView:self];
     return YES;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to