mouseDragged and bindings
Problem: a declared property in a NSView subclass doesn't update members bound to it (with bindings) when in a mouseDragged method. So I have a subclass of NSView that has an ivar that I declare as a property. In IB I have a NSTextField that I set the binding to the same variable (and I do everything required to add the NSView, use an IBOutlet in the AppDelegate, etc). I can confirm that the binding is connected because I set the ivar in the initWithFrame method and the NSTextField shows that value. Also I tried adding a button and connected it to an IBAction method, which worked fine. But when I click and drag the mouse and attempt to update the ivar with self.ivar within the mouseDragged (which I confirmed that it's being called), it doesn't update the ivar. I tried also updating it in the mouseUp method and that didn't work either. The only thing I can think of is it has something to do with the thread that bindings are in, which must be different that the thread that mouseDragged is in, but I can't confirm that nor know how to deal with it. Below is my code for my mouseDragged method. Any help would be greatly appreciated. -(void) mouseDragged:(NSEvent *)theEvent { NSPoint mouseLocation = [theEvent locationInWindow]; NSPoint convertedLocation = [self convertPoint:mouseLocation fromView:nil]; CGFloat difference = convertedLocation.y - dragStart; if([theEvent modifierFlags] NSCommandKeyMask) // command key myDial-rotation = dragDialPos - (difference * 0.5); else myDial-rotation = dragDialPos - (difference * 3); // check limits if(myDial-rotation= dialMaxLeft) myDial-rotation= dialMaxLeft; if(myDial-rotation= dialMaxRight) myDial-rotation= dialMaxRight; // set the dialVal // this assumes that the range is 300 from -150 to 150 self.dialValue = (float) (-(myDial-rotation + 150.0) / 300.0) + 1.0; [selfsetNeedsDisplay:YES]; } GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: afterDelay not working?
Just an update: Thanks for the help guys. I found out I wasn't running on the current loop and didn't realize that time based methods and classes wont work. My flash method was being called in the background. Thanks GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
afterDelay not working?
I have a simple NSView class that is an indicator light that I want to flash. Here are the two methods to perform the flash: -(void) performFlash { if (ledOn) return; ledOn = YES; [selfsetNeedsDisplay:YES]; [selfperformSelector:@selector(endFlash) withObject:nilafterDelay:0.1]; } -(void) endFlash { if (!ledOn) return; NSLog(@Turning off LED); ledOn = NO; [selfsetNeedsDisplay:YES]; } For some reason the afterDelay method isn't working. I know my simple methods work because when I call endFlash independently it works just fine. I have tried every permutation of the afterDelay method, I tried putting it in the delegate class, I tried using a NSTimer scheduleTimerWithTimeInterval: with no success. I am completely stumped on something that should be extremely straightforward. Is there ANY instance where the afterDelay method wont work? I'm pulling my hair out on this one. Thanks GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: afterDelay not working?
Correct, it's not on a different thread. That's why I'm so confused as to why it's not working. :-/ GW Rodriguez Audio Technician South Coast Repertory (c) 909-720-4202 www.gwrodriguez.com On Jan 26, 2012, at 9:12 PM, Jens Alfke j...@mooseyard.com wrote: On Jan 26, 2012, at 8:56 PM, GW Rodriguez wrote: For some reason the afterDelay method isn't working. I know my simple methods work because when I call endFlash independently it works just fine. I have tried every permutation of the afterDelay method, I tried putting it in the delegate class, I tried using a NSTimer scheduleTimerWithTimeInterval: with no success. The code you showed should work. How do you know the perform-after-delay isn't working? Did you set a breakpoint at the start of the -endFlash method to make sure it's not being called? This code is running on the main thread, right? Perform-after-delay probably won't work if invoked on a background thread that doesn't have a runloop. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
getResourceValue:forKey:error: Unrecognized Selector
I am trying to limit files with certain UTI's from dropping into a table view. Here's my code so far: // in the init method I set the registerForDraggedTypes with NSURLPboardType -(NSDragOperation) tableView: (NSTableView*)tv validateDrop: (id NSDraggingInfo)info proposedRow: (int)row proposedDropOperation: (NSTableViewDropOperation)op { NSDragOperationdragOp = NSDragOperationCopy; // if drag source is self its a move unless the option key is pressed if ([info draggingSource] == playlistView) { NSEvent *currentEvent = [NSApp currentEvent]; int optionKey = [currentEvent modifierFlags] NSAlternateKeyMask; if (optionKey == 0) dragOp = NSDragOperationMove; // option not pressed return dragOp; } // if drag source is not self then... OUTSIDE FILE BEING DRAGGED IN NSArray*firstType = [NSArrayarrayWithObjects:NSURLPboardType, nil]; if([[[info draggingPasteboard] types] containsObject:NSURLPboardType] ) { NSString *availableType = [[info draggingPasteboard] availableTypeFromArray:firstType]; NSString *fileType; NSURL *url; NSArray *filesList = [[info draggingPasteboard] propertyListForType:availableType]; for (int i=0; i[filesList count]; ++i) { url = [filesList objectAtIndex:i]; if ([url getResourceValue:fileType forKey:NSURLTypeIdentifierKey error:NULL]) { NSLog(@%@, fileType); // just print the type for now } } } [tv setDropRow:row dropOperation:NSTableViewDropAbove]; return dragOp; } So as I'm sure you've noticed, I'm not changing the dragOp for an outside file being dragged in. For some reason I keep getting an unrecognized selector error with the getResourceValue:forKey:error: method. I'm completely stumped, any help would be greatly appreciated. GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Xcode 3 to 4 - CoreData in IB
Back in Xocde 3 you could drag an entity into IB. With Xcode 4 you can no longer do this. I have found a way to do the exact same thing in IB but miss the ease of use of dragging an entity into IB. Does anyone know if the IB team will be bringing this back in future releases of xcode? PS - I currently have xcode 4.1 GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTableView - Drag/Drop not working
I have gone through many different threads on this, read the docs and went over a few example projects. For some reason I cannot get reordering via drag and drop to work. I have even created a new project with only a NSTableView with one column and pasted code from a working example and it still wont work. My guess is my error is somewhere around the registerForDraggedTypes method because I cannot even start the drag. It only start to highlight multiple selections. I dont fully understand that method and I should also note that all the example projects are document based projects and mine is not. This has been really frustrating because it doesn't seem complex at all, and everything I've read suggest how easy it is. Any help at all would be greatly appreciated. GW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com