Added ITTabView to showcase.
{
NSTabViewItem *_draggedTab;
bool _allowsDragging;
+ unsigned int _requiredModifiers;
}
- (void)setAllowsDragging:(bool)flag;
- (bool)allowsDragging;
+- (void)setRequiredModifiers:(unsigned int)modifiers;
+- (unsigned int)requiredModifiers;
+
- (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index;
if ( (self = [super initWithFrame:frame]) ) {
_draggedTab = nil;
_allowsDragging = NO;
+ _requiredModifiers = NSCommandKeyMask;
}
return self;
}
- (void)setAllowsDragging:(bool)flag
{
_allowsDragging = flag;
+ _requiredModifiers = NSCommandKeyMask;
}
- (bool)allowsDragging
return _allowsDragging;
}
+- (void)setRequiredModifiers:(unsigned int)modifiers
+{
+ _requiredModifiers = modifiers;
+}
+
+- (unsigned int)requiredModifiers
+{
+ return _requiredModifiers;
+}
+
- (void)moveTab:(NSTabViewItem *)tab toIndex:(int)index
{
if ([self indexOfTabViewItem:tab] != index)
- (void)mouseDown:(NSEvent *)event
{
- if ([self allowsDragging]) {
- NSPoint clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
+ if ((_requiredModifiers == 0 || ([[NSApp currentEvent] modifierFlags] & _requiredModifiers)) && [self allowsDragging]) {
+ NSPoint clickedPoint;
+ clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint];
_draggedTab = clickedTab;
}
- (void)mouseUp:(NSEvent *)event
{
- if ([self allowsDragging]) {
+ if (_draggedTab && [self allowsDragging]) {
NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint];
if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) {
- (void)mouseDragged:(NSEvent *)event
{
- if ([self allowsDragging]) {
+ if (_draggedTab && [self allowsDragging]) {
NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint];
if (curTab && ![curTab isEqualTo:_draggedTab]) {
- (IBAction)hideStatusWindow:(id)sender;
- (IBAction)setRotation:(id)sender;
+// ITTabView support
+- (IBAction)toggleTabDragging:(id)sender;
+- (IBAction)toggleCommandDragging:(id)sender;
+- (IBAction)toggleControlDragging:(id)sender;
+- (IBAction)toggleOptionDragging:(id)sender;
+- (IBAction)toggleShiftDragging:(id)sender;
+
@end
{
[self createStatusItem];
[testTextField setCastsShadow:YES];
+ [tabView setAllowsDragging:YES];
statusWindow = [ITTransientStatusWindow sharedWindow];
// [tabView setAllowsDragging:YES];
}
[statusWindow setRotation:([sender floatValue] * (pi / 180))];
}
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITTransientStatusWindow SUPPORT
+/*************************************************************************/
+
+- (IBAction)toggleTabDragging:(id)sender
+{
+ if ([sender state] == NSOnState) {
+ [tabView setAllowsDragging:YES];
+ } else {
+ [tabView setAllowsDragging:NO];
+ }
+}
+
+- (IBAction)toggleCommandDragging:(id)sender
+{
+ if ([sender state] == NSOnState) {
+ [tabView setRequiredModifiers:NSCommandKeyMask];
+ } else {
+ [tabView setRequiredModifiers:0];
+ }
+}
+
+- (IBAction)toggleControlDragging:(id)sender
+{
+}
+
+- (IBAction)toggleOptionDragging:(id)sender
+{
+}
+
+- (IBAction)toggleShiftDragging:(id)sender
+{
+}
/*************************************************************************/
#pragma mark -
setRotation = id;
showStatusWindow = id;
toggleCastsShadow = id;
+ toggleCommandDragging = id;
+ toggleControlDragging = id;
toggleImage = id;
toggleInvertedImage = id;
+ toggleOptionDragging = id;
+ toggleShiftDragging = id;
toggleStatusItem = id;
+ toggleTabDragging = id;
toggleTitle = id;
};
CLASS = Controller;
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
- <string>3 3 356 240 0 0 1056 770 </string>
+ <string>3 3 356 240 0 0 1152 746 </string>
<key>IBEditorPositions</key>
<dict>
<key>197</key>
<string>69 252 75 120 0 0 1056 770 </string>
<key>29</key>
- <string>38 293 349 44 0 0 1056 770 </string>
+ <string>43 283 349 44 0 0 1152 746 </string>
</dict>
<key>IBFramework Version</key>
<string>291.0</string>
<key>IBOpenObjects</key>
<array>
- <integer>29</integer>
<integer>21</integer>
+ <integer>29</integer>
</array>
<key>IBSystem Version</key>
- <string>6G26</string>
+ <string>6G30</string>
</dict>
</plist>