draggable_button.h revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
1// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import <Cocoa/Cocoa.h>
6
7// Class for buttons that can be drag sources. If the mouse is clicked and moved
8// more than a given distance, this class will call |-beginDrag:| instead of
9// |-performClick:|. Subclasses should override these two methods.
10@interface DraggableButton : NSButton {
11 @private
12  BOOL draggable_;     // Is this a draggable type of button?
13}
14
15// Enable or disable dragability for special buttons like "Other Bookmarks".
16@property(nonatomic) BOOL draggable;
17
18// Called when a drag should start. Subclasses must override this to do any
19// pasteboard manipulation and begin the drag, usually with
20// -dragImage:at:offset:event:.  Subclasses must call one of the blocking
21// -drag* methods of NSView when overriding this method.
22- (void)beginDrag:(NSEvent*)dragEvent;
23
24@end  // @interface DraggableButton
25
26@interface DraggableButton (Private)
27
28// Resets the draggable state of the button after dragging is finished.  This is
29// called by DraggableButton when the beginDrag call returns, it should not be
30// called by the subclass.
31- (void)endDrag;
32
33@end  // @interface DraggableButton(Private)
34