selected image in webview
Hi, Is there a way to get the selected item in a webview? I've got a webview in my app, and I'd like to select an image and download it. Many Thanks Amy ___ 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
Re: Literal NSStrings
On Jul 4, 2011, at 5:23 PM, William Squires wrote: > is there ever a situation in which (properly written) client code could call > this and trip over the memory management rules? No, it’s fine. The rule is that if you got it from +alloc or -copy you have to release or autorelease it; but if you didn’t, you don’t care. So returning a string literal is OK. > I would guess that literal NSStrings are (effectively) retained, since > they're not going anywhere (they're literal constants, after all), but > they're not obtained by "New", "alloc", or "copy", which - according to the > memory management rules, means you should retain them because they were > autoreleased. Which is true? Proper procedure is to retain/copy them if you’re going to assign them into an instance or static variable, but in this case it doesn’t really matter because they’re never going to be dealloced. On the other hand, I think it’s better to be safe, as things like this can change. For example, for a long time NSFont objects weren’t ever dealloced, so some developers got lazy about retaining them and just assigned them directly to globals. Then in 10.5(?) they did start getting dealloced when not used, which caused some apps to crash. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Literal NSStrings
On Jul 4, 2011, at 6:23 PM, William Squires wrote: > ...is a literal NSString autoreleased, or retained? Does it matter? "Does not matter" is the answer. You can retain & release them all you want, they're not going anywhere. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ 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
Literal NSStrings
Okay, sorry about this since I think I asked about it previously, but I forgot... If a method (or even a C-style function) returns (NSString *), and I have a method/function like: -(NSString *)bool2String:(BOOL)b { if (!b) { return @"NO"; } return @"YES"; } is there ever a situation in which (properly written) client code could call this and trip over the memory management rules? (as opposed to: -(NSString *)bool2String(BOOL)b { if (!b) { return [NSString stringWithFormat:@"%@", @"NO"); } return [NSString stringWithFormat:@"%@", @"YES"); } which, IIRC, would return an autoreleased NSString, correct?) This is, is a literal NSString autoreleased, or retained? Does it matter? I would guess that literal NSStrings are (effectively) retained, since they're not going anywhere (they're literal constants, after all), but they're not obtained by "New", "alloc", or "copy", which - according to the memory management rules, means you should retain them because they were autoreleased. Which is true? ___ 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
Re: Dumb question about multi-column NSTableViews
On Jul 4, 2011, at 5:29 PM, William Squires wrote: > Do individual table columns have a 'Tag' value that can be set so I can find > out which column the tableview delegate/datasource is working with? (I want > to set the tag value to an NSString that's the key value in an NSDictionary, > then fetch the value for that key-value pair to set the contents of the > cell)___ For table columns is called "identifier"; you can set it in IB, and get it in code. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ 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
Dumb question about multi-column NSTableViews
Do individual table columns have a 'Tag' value that can be set so I can find out which column the tableview delegate/datasource is working with? (I want to set the tag value to an NSString that's the key value in an NSDictionary, then fetch the value for that key-value pair to set the contents of the cell)___ 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
Re: finder eject images
Lee Ann and Patrick, thank you! I suspect the one from ../coreservices/menu extras/Eject.menu uses the character set one as well. They converted to a pdf for displaying as an image. Again, thank you. Tony Romano On 7/4/11 12:52 PM, "Lee Ann Rucker" wrote: >That's not the Finder sidebar icon, though. I'm not sure I've seen >anything use that one. > >Also I think Apple frowns on copying their icons into your apps. Only the >ones you can get through imageNamed: or iconForFileType: are fair game. > >- Original Message - >From: "Patrick Robertson" >To: Cocoa-dev@lists.apple.com >Sent: Monday, July 4, 2011 12:24:20 PM >Subject: Re: finder eject images > >Lots of system icons are stored in > >/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ > >EjectMediaIcon.icns is in there :) > >On 4 July 2011 20:21, Lee Ann Rucker wrote: > >> Unicode "eject symbol" 23CF, possibly in Apple Symbols font: ⏏ >> >> - Original Message - >> From: "Tony Romano" >> To: "List Cocoa Developer" >> Sent: Monday, July 4, 2011 12:16:02 PM >> Subject: finder eject images >> >> Not quite a cocoa questionŠ >> >> By chance, does somewhere know where the images are for the eject >>button in >> finder. I looked in /system/library/coreservices/finder and they are >>not >> bundled with it. I'd prefer the Mac OS X versions and not some 3rd >>party. >> Thanks in advance. >> >> Tony Romano >> >> >> >> >> >> ___ >> >> 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/lrucker%40vmware.com >> >> This email sent to lruc...@vmware.com >> ___ >> >> 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/robertson.patrick%40gmai >>l.com >> >> This email sent to robertson.patr...@gmail.com >> >___ > >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/lrucker%40vmware.com > >This email sent to lruc...@vmware.com >___ > >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/tonyrom%40hotmail.com > >This email sent to tony...@hotmail.com ___ 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
Re: Animating a flickering display
The purpose of the program is to compare the visibility of the text when it is static versus when it flickers (so in some ways it's similar to signage). Therefore, I must make the text display switch back and forth between two displays with opposite black/white contrast to produce the flicker -- either a sudden swap or easing in/out are acceptable, as long as the switching back and forth can be repeated indefinitely at a given rate and does not block other GUI actions (a button press will be used to stop the animation). The smoothness of the font via anti-aliasing is not that important. I hope that this is enough information to make the task more understandable. Scott On Jul 4, 2011, at 2:30 PM, Kyle Sluder wrote: > On Mon, Jul 4, 2011 at 11:31 AM, Dr. Scott Steinman wrote: >> My program needs to display counterphase flickering test, i.e., one display >> is white text on a black background, and the other is black text on a white >> background, and the two displays are switched back and forth. I have >> concluded that there are two options to do this: > > It might help to explain what you're doing in more detail. Is this for > signage, or for testing video monitors, or what? Do you want the > animation to ease in/out, or abruptly swap periodically? Is the text > dynamic? Do you care about subpixel anti-aliasing? > > --Kyle Sluder Scott Steinman, O.D., Ph.D. Sent from my iPad ___ 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
Re: finder eject images
That's not the Finder sidebar icon, though. I'm not sure I've seen anything use that one. Also I think Apple frowns on copying their icons into your apps. Only the ones you can get through imageNamed: or iconForFileType: are fair game. - Original Message - From: "Patrick Robertson" To: Cocoa-dev@lists.apple.com Sent: Monday, July 4, 2011 12:24:20 PM Subject: Re: finder eject images Lots of system icons are stored in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ EjectMediaIcon.icns is in there :) On 4 July 2011 20:21, Lee Ann Rucker wrote: > Unicode "eject symbol" 23CF, possibly in Apple Symbols font: ⏏ > > - Original Message - > From: "Tony Romano" > To: "List Cocoa Developer" > Sent: Monday, July 4, 2011 12:16:02 PM > Subject: finder eject images > > Not quite a cocoa questionŠ > > By chance, does somewhere know where the images are for the eject button in > finder. I looked in /system/library/coreservices/finder and they are not > bundled with it. I'd prefer the Mac OS X versions and not some 3rd party. > Thanks in advance. > > Tony Romano > > > > > > ___ > > 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/lrucker%40vmware.com > > This email sent to lruc...@vmware.com > ___ > > 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/robertson.patrick%40gmail.com > > This email sent to robertson.patr...@gmail.com > ___ 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/lrucker%40vmware.com This email sent to lruc...@vmware.com ___ 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
Re: Animating a flickering display
On Mon, Jul 4, 2011 at 11:31 AM, Dr. Scott Steinman wrote: > My program needs to display counterphase flickering test, i.e., one display > is white text on a black background, and the other is black text on a white > background, and the two displays are switched back and forth. I have > concluded that there are two options to do this: It might help to explain what you're doing in more detail. Is this for signage, or for testing video monitors, or what? Do you want the animation to ease in/out, or abruptly swap periodically? Is the text dynamic? Do you care about subpixel anti-aliasing? --Kyle Sluder ___ 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
Re: finder eject images
Lots of system icons are stored in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ EjectMediaIcon.icns is in there :) On 4 July 2011 20:21, Lee Ann Rucker wrote: > Unicode "eject symbol" 23CF, possibly in Apple Symbols font: ⏏ > > - Original Message - > From: "Tony Romano" > To: "List Cocoa Developer" > Sent: Monday, July 4, 2011 12:16:02 PM > Subject: finder eject images > > Not quite a cocoa questionŠ > > By chance, does somewhere know where the images are for the eject button in > finder. I looked in /system/library/coreservices/finder and they are not > bundled with it. I'd prefer the Mac OS X versions and not some 3rd party. > Thanks in advance. > > Tony Romano > > > > > > ___ > > 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/lrucker%40vmware.com > > This email sent to lruc...@vmware.com > ___ > > 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/robertson.patrick%40gmail.com > > This email sent to robertson.patr...@gmail.com > ___ 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
Re: finder eject images
Unicode "eject symbol" 23CF, possibly in Apple Symbols font: ⏏ - Original Message - From: "Tony Romano" To: "List Cocoa Developer" Sent: Monday, July 4, 2011 12:16:02 PM Subject: finder eject images Not quite a cocoa questionŠ By chance, does somewhere know where the images are for the eject button in finder. I looked in /system/library/coreservices/finder and they are not bundled with it. I'd prefer the Mac OS X versions and not some 3rd party. Thanks in advance. Tony Romano ___ 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/lrucker%40vmware.com This email sent to lruc...@vmware.com ___ 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
finder eject images
Not quite a cocoa question By chance, does somewhere know where the images are for the eject button in finder. I looked in /system/library/coreservices/finder and they are not bundled with it. I'd prefer the Mac OS X versions and not some 3rd party. Thanks in advance. Tony Romano ___ 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
Re: Animating a flickering display
On Jul 4, 2011, at 11:31 AM, Dr. Scott Steinman wrote: > I have concluded that there are two options to do this: > > 1. Draw each display into two NSViews, then switch back and forth between > between them (via replaceSubview:with:) with an NSTimer to time the switches. > 2. Use Core Animation to fade in one display and fade in the other. I would just use a single view that has a boolean state, like _drawBlackText, and use a repeating NSTimer to trigger a method that flips the variable and tells the view to redraw. > In each case, I don't know how to avoid blocking a button presses whose > action would stop the animation. Normally a timer will only run in NSDefaultRunloopMode, i.e. while the app is idle. But while a control is tracking mouse events, it runs a nested runloop in NSEventTrackingRunloopMode. If you want the timer to fire during the mouse-down, you’ll need to make it run in that mode as well; see the NSRunLoop API for details. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why is a button in a window not redrawn when I change its state?
On Jul 4, 2011, at 10:48 AM, Ulf Dunkel wrote: > Thank you for this hint, Alexander. I wasn't aware that I was still inside > the action and that the poor button couldn't do then what I asked it to do. It’s OK to call -setEnabled: during a button action method. I’ve done it a lot. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why is a button in a window not redrawn when I change its state?
On Jul 4, 2011, at 8:07 AM, Ulf Dunkel wrote: > This is the method in my AppDelegate.m which should update the button: > > - (void)updateKillHelpdButton > { > [killHelpdButton setEnabled:[self checkHelpd]]; > [killHelpdButton setNeedsDisplay:YES]; > } > > Can someone please tell me what else I should do to force the redraw? That should work; in fact, you don’t even need the -setNeedsDisplay: call. - Is this method being called when you expect? Set a breakpoint in it, or add an NSLog call. - Is killHelpdButton set to the right value, e.g. non-nil? - Are you calling this on a background thread? In general you should only call AppKit from the main thread. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Animating a flickering display
My program needs to display counterphase flickering test, i.e., one display is white text on a black background, and the other is black text on a white background, and the two displays are switched back and forth. I have concluded that there are two options to do this: 1. Draw each display into two NSViews, then switch back and forth between between them (via replaceSubview:with:) with an NSTimer to time the switches. 2. Use Core Animation to fade in one display and fade in the other. In each case, I don't know how to avoid blocking a button presses whose action would stop the animation. Which is the better way to proceed? How do I keep the user interface responsive? Please point me in the right direction. Thank you. Scott ___ 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
Re: Why is a button in a window not redrawn when I change its state?
Thank you for this hint, Alexander. I wasn't aware that I was still inside the action and that the poor button couldn't do then what I asked it to do. I was quite sure that using -setNeedsDisplay:YES would trigger some auto-redraw stuff somewhen later in the application. - - - - - Am 04.07.2011 17:58, schrieb Alexander Spohr: Your Button has to draw itself after it called its action. You try to change state while you are still in the action. Did you try to performSelector after 0.0? In my app's main window, I have a button which should kill a process from the running system processes. (Guess what - it is helpd.) In -awakeFromNib:, a private app delegate method -checkHelpd: checks if some other app has already launched helpd. If so, the button will be drawn as enabled, else disabled. When I press the button, another private method -killHelpd: definitely kills the process, then -checkHelpd: is used again to check whether the button's state should be disabled or enabled. This triggers a redraw of the window - or at least should do. But the button is not redrawn (with its new state) until I toggle the active app from my app to say Xcode and back to my app. This is the method in my AppDelegate.m which should update the button: - (void)updateKillHelpdButton { [killHelpdButton setEnabled:[self checkHelpd]]; [killHelpdButton setNeedsDisplay:YES]; } Can someone please tell me what else I should do to force the redraw? ___ 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
Problem when load nib file
Hi, I'm working with AQGridView, and when I load the nib file, he also load an square white ahead of elements. In this project, I also implemented - (CGSize) portraitGridCellSizeForGridView: (AQGridView *) gridView; { return CGSizeMake(250, 400); } And when I change this values, the size of square also change. Looks like that: http://cl.ly/1S223X2u23081Y1i3U0R How i fix that? Thanks! -- *Fernando Aureliano* ___ 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
Re: Runloop not being stopped by CFRunLoopStop?
> Is there a reason that you're using -[NSRunLoop runUntilDate:] instead of > CFRunLoopRun()? Not really, and it was a bit daft to use NSRunLoop to start it off and then CFRunLoop to stop it. Anyway, your solution worked perfectly. Thanks Matt On 4 Jul 2011, at 17:58:31, Jeff Johnson wrote: > Hi Matt. > > Is there a reason that you're using -[NSRunLoop runUntilDate:] instead of > CFRunLoopRun()? > > According to the documentation, runUntilDate: "runs the receiver in the > NSDefaultRunLoopMode by repeatedly invoking runMode:beforeDate: until the > specified expiration date." So even if CFRunLoopStop() stops one invocation > of runMode:beforeDate:, it won't necessarily stop subsequent invocations. > Furthermore, "Manually removing all known input sources and timers from the > run loop is not a guarantee that the run loop will exit. Mac OS X can install > and remove additional input sources as needed to process requests targeted at > the receiver’s thread. Those sources could therefore prevent the run loop > from exiting." > > -Jeff > > > On Jul 4, 2011, at 11:36 AM, Matt Gough wrote: > >> I have a runloop running in an NSThread. In this thread is a timer which >> fires every 2 seconds. In the timer, I check [NSThread isCancelled] and if >> so, stop the runloop via CFRunLoopStop. >> >> The runloop is run via runUntilDate:distantFuture. >> >> Shouldn't runUntilDate terminate once CFRunLoopStop has been called on it? >> >> Here is the pertinent code: >> >> >> - (void)gatheringTimer:(NSTimer*)timer >> { >> if ([[NSThread currentThread] isCancelled]) >> { >> [timer invalidate]; >> CFRunLoopStop(CFRunLoopGetCurrent()); >> return; >> } >> >> // Real code goes here to do handle the timer >> } >> >> - (void)doGathering:(id)object >> { >> NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; >> >> [NSTimer scheduledTimerWithTimeInterval:2.0 >> >> target:self >> >> selector:@selector(gatheringTimer:) >> userInfo:nil >> >> repeats:YES]; >> >> [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; >> >> [pool drain]; >> } >> >> - (void)startGathering >> { >> if (!_gatheringThread) >> { >> _gatheringThread = [[NSThread alloc] initWithTarget:self >> selector:@selector(doGathering:) object:nil]; >> [_gatheringThread start]; >> } >> } >> >> - (void)stopGathering >> { >> if (_gatheringThread) >> { >> [_gatheringThread cancel]; >> [_gatheringThread release]; >> _gatheringThread = nil; >> } >> } >> >> >> I have verified that CFRunLoopStop is being called, but doGathering never >> finishes >> >> Any ideas? >> >> Thanks >> >> Matt > ___ 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
Re: Runloop not being stopped by CFRunLoopStop?
On 4 Jul 2011, at 17:36, Matt Gough wrote: > I have a runloop running in an NSThread. In this thread is a timer which > fires every 2 seconds. In the timer, I check [NSThread isCancelled] and if > so, stop the runloop via CFRunLoopStop. > > The runloop is run via runUntilDate:distantFuture. > > Shouldn't runUntilDate terminate once CFRunLoopStop has been called on it? > > > I have verified that CFRunLoopStop is being called, but doGathering never > finishes > > Any ideas? > 1 idea. In my case I call NSApp stop rather than accessing the runloop directly. I find that the run loop will exit after the next event is dispatched. If there is no next event then I don't see my runloop exit. Therefore I generate a trigger event. Having a timer active isn't sufficient. - (void)stopApp:(id)sender { #pragma unused(sender) // will stop run loop after next actual event object dispatched. // a timer doesn't count here [NSApp stop:self]; // send a dummy event to trigger stopping NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0,0) modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:1 data1:1 data2:1]; [NSApp postEvent:event atStart:YES]; } Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.com ___ 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
Re: Runloop not being stopped by CFRunLoopStop?
Hi Matt. Is there a reason that you're using -[NSRunLoop runUntilDate:] instead of CFRunLoopRun()? According to the documentation, runUntilDate: "runs the receiver in the NSDefaultRunLoopMode by repeatedly invoking runMode:beforeDate: until the specified expiration date." So even if CFRunLoopStop() stops one invocation of runMode:beforeDate:, it won't necessarily stop subsequent invocations. Furthermore, "Manually removing all known input sources and timers from the run loop is not a guarantee that the run loop will exit. Mac OS X can install and remove additional input sources as needed to process requests targeted at the receiver’s thread. Those sources could therefore prevent the run loop from exiting." -Jeff On Jul 4, 2011, at 11:36 AM, Matt Gough wrote: > I have a runloop running in an NSThread. In this thread is a timer which > fires every 2 seconds. In the timer, I check [NSThread isCancelled] and if > so, stop the runloop via CFRunLoopStop. > > The runloop is run via runUntilDate:distantFuture. > > Shouldn't runUntilDate terminate once CFRunLoopStop has been called on it? > > Here is the pertinent code: > > > - (void)gatheringTimer:(NSTimer*)timer > { > if ([[NSThread currentThread] isCancelled]) > { > [timer invalidate]; > CFRunLoopStop(CFRunLoopGetCurrent()); > return; > } > > // Real code goes here to do handle the timer > } > > - (void)doGathering:(id)object > { > NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; > > [NSTimer scheduledTimerWithTimeInterval:2.0 > > target:self > > selector:@selector(gatheringTimer:) > userInfo:nil > > repeats:YES]; > > [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; > > [pool drain]; > } > > - (void)startGathering > { > if (!_gatheringThread) > { > _gatheringThread = [[NSThread alloc] initWithTarget:self > selector:@selector(doGathering:) object:nil]; > [_gatheringThread start]; > } > } > > - (void)stopGathering > { > if (_gatheringThread) > { > [_gatheringThread cancel]; > [_gatheringThread release]; > _gatheringThread = nil; > } > } > > > I have verified that CFRunLoopStop is being called, but doGathering never > finishes > > Any ideas? > > Thanks > > Matt ___ 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
Runloop not being stopped by CFRunLoopStop?
I have a runloop running in an NSThread. In this thread is a timer which fires every 2 seconds. In the timer, I check [NSThread isCancelled] and if so, stop the runloop via CFRunLoopStop. The runloop is run via runUntilDate:distantFuture. Shouldn't runUntilDate terminate once CFRunLoopStop has been called on it? Here is the pertinent code: - (void)gatheringTimer:(NSTimer*)timer { if ([[NSThread currentThread] isCancelled]) { [timer invalidate]; CFRunLoopStop(CFRunLoopGetCurrent()); return; } // Real code goes here to do handle the timer } - (void)doGathering:(id)object { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(gatheringTimer:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; [pool drain]; } - (void)startGathering { if (!_gatheringThread) { _gatheringThread = [[NSThread alloc] initWithTarget:self selector:@selector(doGathering:) object:nil]; [_gatheringThread start]; } } - (void)stopGathering { if (_gatheringThread) { [_gatheringThread cancel]; [_gatheringThread release]; _gatheringThread = nil; } } I have verified that CFRunLoopStop is being called, but doGathering never finishes Any ideas? Thanks Matt ___ 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
Re: Bundled Image scaled down when displayed (drawAtPoint) - Thank you
Jens, Quincey, Thank you for all the valuable info. My image dpi is indeed higher than 72. Combining your info, I elected to use, for now: NSImage* tempImage = [NSImage imageNamed: @"image1"]; NSImageRep *rep = [tempImage bestRepresentationForDevice: nil]; int width = (int)rep.pixelsWide; int height = (int)rep.pixelsHigh; [tempImage setSize:NSMakeSize(width, height)]; [tempImage drawAtPoint:point fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0]; [tempImage release]; Thanks again, Ben ___ 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
Re: Why is a button in a window not redrawn when I change its state?
Your Button has to draw itself after it called its action. You try to change state while you are still in the action. Did you try to performSelector after 0.0? Am 04.07.2011 um 17:07 schrieb Ulf Dunkel: > In my app's main window, I have a button which should kill a process from the > running system processes. (Guess what - it is helpd.) > > In -awakeFromNib:, a private app delegate method -checkHelpd: checks if some > other app has already launched helpd. If so, the button will be drawn as > enabled, else disabled. > > When I press the button, another private method -killHelpd: definitely kills > the process, then -checkHelpd: is used again to check whether the button's > state should be disabled or enabled. This triggers a redraw of the window - > or at least should do. But the button is not redrawn (with its new state) > until I toggle the active app from my app to say Xcode and back to my app. > > This is the method in my AppDelegate.m which should update the button: > > - (void)updateKillHelpdButton > { > [killHelpdButton setEnabled:[self checkHelpd]]; > [killHelpdButton setNeedsDisplay:YES]; > } > > Can someone please tell me what else I should do to force the redraw? > > Thank you in advance, > ---Ulf Dunkel > ___ > > 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/atze%40freeport.de > > This email sent to a...@freeport.de ___ 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
Why is a button in a window not redrawn when I change its state?
In my app's main window, I have a button which should kill a process from the running system processes. (Guess what - it is helpd.) In -awakeFromNib:, a private app delegate method -checkHelpd: checks if some other app has already launched helpd. If so, the button will be drawn as enabled, else disabled. When I press the button, another private method -killHelpd: definitely kills the process, then -checkHelpd: is used again to check whether the button's state should be disabled or enabled. This triggers a redraw of the window - or at least should do. But the button is not redrawn (with its new state) until I toggle the active app from my app to say Xcode and back to my app. This is the method in my AppDelegate.m which should update the button: - (void)updateKillHelpdButton { [killHelpdButton setEnabled:[self checkHelpd]]; [killHelpdButton setNeedsDisplay:YES]; } Can someone please tell me what else I should do to force the redraw? Thank you in advance, ---Ulf Dunkel ___ 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
Re: How Do I get informed when -showHelp: has been called?
Thank you all for pointing me to the solution of my question. My first thought was that you could change the target of the menu item so that it calls your own method, then call the original showHelp method with something like: [NSApp showHelp:sender] This is what I did now, using an own -myShowHelp: method which calls [NSApp showHelp:sender], when other things have been prepared. This of course opens the Help Viewer. No need to subclass NSApplication and to override showHelp: at all. - (IBAction)myShowHelp:(id)sender { [... do some stuff]; [NSApp showHelp:sender]; [... do some other stuff]; } ---Ulf Dunkel ___ 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
Re: Line Drawing problem
On 4 Jul 2011, at 7:17 AM, Dale Satterfield wrote: > Well, hopefully that code is correct since it is the unmodified code from the > book. The code you are looking to is intended as an example of how to prepare a Mac OS X framework, not as a graphics tutorial. The source had to fit into a reasonably-sized book, and that entailed a sacrifice in drawing performance. In particular, I scaled the drawing view to make the graph fit. As the source data's aspect ratio departs from 1, lines perpendicular to the compressed axis will be compressed to less than a full pixel (actually, point) width, and get antialiased to gray. You should find other examples. — F ___ 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
Re: Line Drawing problem
Well, hopefully that code is correct since it is the unmodified code from the book. I have a Davis Weatherstation and the console talks to the Mac via USB. Davis has had very sporadic Mac support, and their application which used to run under Mac OSX, but badly, won't run at all under current versions. In addition, I wanted to learn Objective-C and Cocoa, having done mostly C and C++ work previously. So the data I am trying to plot is inside/outside temps, wind speeds, barometric pressures, etc. I have put the original image, plus the non-antialiaed one in my public iDisk folder. idisk.mac.com/dsatterfield//Public On Jul 3, 2011, at 6:44 PM, Jens Alfke wrote: > > On Jul 3, 2011, at 5:39 PM, Dale Satterfield wrote: > >> Hopefully this image will show in your email. Note that the horizontal lines >> though much thinner, at least now show up as black with the anti-aliasing >> turned off. I still have to have anti-aliasing on, >> so I still have the problem, as well as the diagonal lines >> thicker than >> horizontal issue. Not sure how to fix that either, as there are no "brushes" >> that I can see discussed in the Cocoa drawing guide. > > You must have a bug in how you’re calculating ‘unitSize’, since that’s what > determines the line width. You didn’t show that code, and it’s not really > relevant here since your use of Cocoa APIs seems correct. You haven’t > explained what it is you’re trying to do, either. > > —Jens Dale Satterfield dsatterfi...@mac.com ___ 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