Revision: 12139
http://sourceforge.net/p/skim-app/code/12139
Author: hofman
Date: 2021-02-28 21:37:42 +0000 (Sun, 28 Feb 2021)
Log Message:
-----------
Set clickedIndex only when clicking
Modified Paths:
--------------
trunk/SKColorSwatch.m
Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m 2021-02-28 21:27:47 UTC (rev 12138)
+++ trunk/SKColorSwatch.m 2021-02-28 21:37:42 UTC (rev 12139)
@@ -385,12 +385,10 @@
NSPoint mouseLoc = [theEvent locationInView:self];
NSInteger i = [self colorIndexAtPoint:mouseLoc];
- if ([self isEnabled]) {
- clickedIndex = i;
- [[itemViews objectAtIndex:i] setHighlighted:YES];
- }
-
if (i != -1) {
+ if ([self isEnabled])
+ [[itemViews objectAtIndex:i] setHighlighted:YES];
+
BOOL keepOn = YES;
while (keepOn) {
theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask
| NSLeftMouseDraggedMask];
@@ -397,11 +395,8 @@
switch ([theEvent type]) {
case NSLeftMouseDragged:
{
- if ([self isEnabled]) {
- if (clickedIndex != -1)
- [[itemViews objectAtIndex:clickedIndex]
setHighlighted:NO];
- clickedIndex = -1;
- }
+ if ([self isEnabled])
+ [[itemViews objectAtIndex:i] setHighlighted:NO];
draggedIndex = i;
@@ -431,9 +426,9 @@
else
[self selectColorAtIndex:i];
}
+ clickedIndex = i;
[self sendAction:[self action] to:[self target]];
- if (clickedIndex != -1)
- [[itemViews objectAtIndex:clickedIndex]
setHighlighted:NO];
+ [[itemViews objectAtIndex:i] setHighlighted:NO];
clickedIndex = -1;
}
keepOn = NO;
@@ -526,8 +521,7 @@
}
- (NSColor *)color {
- NSInteger i = clickedIndex;
- return i == -1 ? nil : [colors objectAtIndex:i];
+ return clickedIndex == -1 ? nil : [colors objectAtIndex:clickedIndex];
}
- (void)setEnabled:(BOOL)enabled {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit