зеркало из https://github.com/mozilla/pjs.git
Add code to DraggableImageAndTextCell to make it possible to tell when the mouse has been down on the cell without moving (click-hold).
This commit is contained in:
Родитель
6d4df4405d
Коммит
6d83929f7c
|
@ -46,8 +46,10 @@
|
|||
float mImagePadding;
|
||||
float mImageSpace;
|
||||
float mImageAlpha;
|
||||
float mClickHoldTimeoutSeconds;
|
||||
BOOL mTruncateLabel;
|
||||
BOOL mIsDraggable;
|
||||
BOOL mLastClickHoldTimedOut;
|
||||
}
|
||||
|
||||
- (id)initTextCell:(NSString*)aString;
|
||||
|
@ -65,5 +67,8 @@
|
|||
- (BOOL)isDraggable;
|
||||
- (void)setDraggable:(BOOL)inDraggable;
|
||||
|
||||
- (void)setClickHoldTimeout:(float)timeoutSeconds;
|
||||
- (BOOL)lastClickHoldTimedOut;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -60,7 +60,10 @@
|
|||
mLabelStringWidth = -1;
|
||||
mImagePadding = 0;
|
||||
mImageSpace = 2;
|
||||
mImageAlpha = 1.0;
|
||||
mIsDraggable = NO;
|
||||
mClickHoldTimeoutSeconds = 60.0 * 60.0 * 24.0;
|
||||
mLastClickHoldTimedOut = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -193,6 +196,17 @@
|
|||
mTruncLabelString = nil;
|
||||
}
|
||||
|
||||
- (void)setClickHoldTimeout:(float)timeoutSeconds
|
||||
{
|
||||
mClickHoldTimeoutSeconds = timeoutSeconds;
|
||||
}
|
||||
|
||||
- (BOOL)lastClickHoldTimedOut
|
||||
{
|
||||
return mLastClickHoldTimedOut;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (BOOL)isDraggable
|
||||
|
@ -232,6 +246,8 @@
|
|||
|
||||
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp
|
||||
{
|
||||
mLastClickHoldTimedOut = NO;
|
||||
|
||||
if (!mIsDraggable)
|
||||
return [super trackMouse:theEvent inRect:cellFrame ofView:controlView untilMouseUp:untilMouseUp];
|
||||
|
||||
|
@ -239,6 +255,7 @@
|
|||
NSPoint lastWindowLocation = firstWindowLocation;
|
||||
NSPoint curWindowLocation = firstWindowLocation;
|
||||
NSEventType lastEvent = (NSEventType)0;
|
||||
NSDate* clickHoldBailTime = [NSDate dateWithTimeIntervalSinceNow:mClickHoldTimeoutSeconds];
|
||||
|
||||
if (![self startTrackingAt:curWindowLocation inView:controlView])
|
||||
return NO;
|
||||
|
@ -247,9 +264,14 @@
|
|||
{
|
||||
NSEvent* event = [NSApp nextEventMatchingMask:
|
||||
(NSLeftMouseDraggedMask | NSLeftMouseUpMask)
|
||||
untilDate:nil
|
||||
untilDate:clickHoldBailTime
|
||||
inMode:NSEventTrackingRunLoopMode
|
||||
dequeue:YES];
|
||||
if (!event)
|
||||
{
|
||||
mLastClickHoldTimedOut = YES;
|
||||
break;
|
||||
}
|
||||
|
||||
curWindowLocation = [event locationInWindow];
|
||||
lastEvent = [event type];
|
||||
|
|
Загрузка…
Ссылка в новой задаче