Extending NSTextStorage

2011-05-11 Thread Дмитрий Николаев
Hello!

According to documentation, I try to subclass NSTextStorage and use it in text 
view:

/*
NSTextStorage is a semi-abstract subclass of NSMutableAttributedString. It 
implements change management (beginEditing/endEditing), verification of 
attributes, delegate handling, and layout management notification. The one 
aspect it does not implement is the actual attributed string storage --- this 
is left up to the subclassers, which need to override the two 
NSMutableAttributedString primitives:

  - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
  - (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range;

*/

So I try to use delegate, to handle all needed events with same functionality:

 code --

@implementation MyTextStorage

- (id) init {
self = [super init];

if (self != nil) {
storage = [[NSMutableAttributedString alloc] init];
}

return self;
}

- (void) dealloc {
[storage release];
[super dealloc];
}

- (NSString *) string {
return [storage string];
}

- (void) replaceCharactersInRange:(NSRange)range withString:(NSString *)str {
[storage replaceCharactersInRange:range withString:str];
}

- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range {
[storage setAttributes:attrs range:range];
}


@end

 /code --

It is no matter what I'm use as delegate: NSTextStorage or 
NSMutableAttributedString, The result is the same:

 log ---

An uncaught exception was raised
*** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) beyond 
array bounds (0)
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** 
NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) beyond 
array bounds (0)'

 /log ---

What I need to do to extend this class ?


___

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: PDFDocument and CGPDFDocument

2011-05-11 Thread Antonio Nunes
On 11 May 2011, at 03:59, Graham Cox wrote:

> Are CGPDFDocument and PDFDocument toll-free bridged? If not, how can I get a 
> PDFDocument from a CGPDFDocumentRef? 

They are not toll-free bridged.

> I need to use the lower level API to extract graphic entities from a PDF, but 
> I'd like to use PDFKit up-front to implement a page chooser.

How about opening the document with PDFKit to start with, and then ask the 
obtained PDFDocument for its documentRef when you need to get submerged. I 
don't think you can go the other way.

The 'documentRef' is in the PDFDocument header file.
- (CGPDFDocumentRef) documentRef;

 I did not find it in the docs. Apple's doc team alerted.

Best,
António

---
Touch is a language without words
---




___

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 NSClassFromString(@"CADisplayLink")?

2011-05-11 Thread Brian Bruinewoud
Thanks for the various answers.

Hank said:
If the class is missing, NSClassFromString(@"CADisplayLink") returns nil. When 
you say that it "compiles and runs", does that mean that line of code puts a 
non-nil value in displayLink?

My Response:
The code functions only because displayLink is non-Nil. So NSClassFromString is 
returning something otherwise my display link delegate would never get called.

David said:
These types of link errors typically indicate that you forgot to link a 
necessary framework, in this case QuartzCore.framework

My Response:
Ok. But I'm using core animation in my app, which requires that framework 
anyway so I assume it would be included. If not, then why is anything running? 
Will it die when I try to run it on the real device (something I can't test at 
the moment)?

FYI:
This code was from the Apple Sample code - for an OpenGL iPhone app, I believe.

Thanks for your answers - I'll check the XCode project as soon as I'm able.

On 10/05/2011, at 20:34 , Brian Bruinewoud wrote:

> Hi All,
> 
> Just curious, why does this work (compiles and runs):
> 
>displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget: 
> tapped selector:@selector(respond:)];
> 
> But this doesn't link because the CADisplayLink class is missing:
> 
>displayLink = [CADisplayLink   displayLinkWithTarget: 
> tapped selector:@selector(respond:)];
> 
> ??
> 
> Link error is:
> 
> Undefined symbols for architecture i386:
>  "_OBJC_CLASS_$_CADisplayLink", referenced from:
>  objc-class-ref in drawingViewController.o
> ld: symbol(s) not found for architecture i386
> collect2: ld returned 1 exit status
> 
> Using XCode 4.0 and the iPad simulator. I suppose if I compiled for ARM the 
> error might go away (but I don't have provisioning profile so I can't test 
> that). Still, the code still runs so it must be able to link at run time even 
> if it can't at compile time, which seems strange.
> 
> Anyway, just curious.
> 
> Regards,
> Brian.
> 
> ___
> 
> 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/brian%40darknova.com
> 
> This email sent to br...@darknova.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: PDFDocument and CGPDFDocument

2011-05-11 Thread Graham Cox

On 11/05/2011, at 6:33 PM, Antonio Nunes wrote:

> How about opening the document with PDFKit to start with, and then ask the 
> obtained PDFDocument for its documentRef when you need to get submerged. I 
> don't think you can go the other way.
> 
> The 'documentRef' is in the PDFDocument header file.
> - (CGPDFDocumentRef) documentRef;


Ah, good to know - I hadn't checked out the headers, just the class reference. 
I assumed that PDFDocument was a wrapper on CGPDFDocument, but didn't see 
anything that exposed that. Thanks!

I already changed the code to work this way round actually,  since it was 
obviously easier.

On a follow-up note, I'm using PDFView and PDFThumbView in a modal dialog to 
pick the page to open (since it's part of opening a file I don't yet have a 
document to hang a sheet from). The main page view works fine but I notice that 
the thumbnail images apart from the first don't get updated during the modal 
dialog, only when the modal session ends. If I run the window modelessly it 
works normally. Anyone know anything about this, and how to fix it? I'd guess 
that some timer is used to update the thumbs and it's not being run in the 
modal loop mode.


--Graham


___

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: PDFDocument and CGPDFDocument

2011-05-11 Thread Graham Cox

On 11/05/2011, at 10:34 PM, Graham Cox wrote:

> On a follow-up note, I'm using PDFView and PDFThumbView in a modal dialog to 
> pick the page to open (since it's part of opening a file I don't yet have a 
> document to hang a sheet from). The main page view works fine but I notice 
> that the thumbnail images apart from the first don't get updated during the 
> modal dialog, only when the modal session ends. If I run the window 
> modelessly it works normally. Anyone know anything about this, and how to fix 
> it? I'd guess that some timer is used to update the thumbs and it's not being 
> run in the modal loop mode.


I found a hack that does get this to work, but as it involves "kicking" the run 
loop during a modal session, I dunno if it's really legal.

Trying to force the thumb view to display in the modal session doesn't work, so 
my guess is that a timer is used to fetch the the page to be rendered as a 
thumbnail and that's what's blocking, not the repaint. This code in the modal 
dialog's window controller.



NSModalSession  session = [NSApp 
beginModalSessionForWindow:[self window]];
NSInteger   result;

while( 1 )
{
result = [NSApp runModalSession:session];

if( result != NSRunContinuesResponse )
break;

// force run loop to run in standard mode so that  thumbs get 
updated:

[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 
beforeDate:[NSDate date]];
}

[NSApp endModalSession:session];



--Graham


___

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: Call NSView's -drawRect method manually

2011-05-11 Thread Nick
Thanks for a detailed explanation

2011/5/11 Ken Thomases :
> On May 10, 2011, at 11:26 AM, Nick wrote:
>
>> Can someone explain please, when an NSView's call -drawRect
>> (being called manually - not by a framework) actually initiates
>> redrawing of the frame and displaying everything that it had drawn,
>> and when this call "doesn't initiate a thing"?
>
> When the framework calls your -drawRect: method, it has already established a 
> graphics context and configured it as appropriate for the view.  If you just 
> call it yourself, there's either no current graphics context or some 
> arbitrary graphics context that isn't related to your view.
>
> It's conceivable that one could manually set up the graphics context and then 
> call -drawRect: oneself, but it's going to be complicated and error-prone.  
> It is not advised
>
> Search the documentation for the -lockFocus... methods of NSView -- not just 
> the class reference, but also the mentions of it in the View Programming 
> Guide (the Advanced Custom View Tasks page) and the Threading Programming 
> Guide (the Thread Safety Summary page).  That latter is especially important 
> since you're working with a display link, which calls your callback on a 
> secondary thread.  It couldn't hurt to read about graphics contexts in the 
> Quartz 2D Programming Guide and Cocoa Drawing Guide.
>
> All of that said, you should always think twice about fighting the 
> frameworks, as has been said by others.  Chances are you're doing something 
> you shouldn't be or are making your life harder for no good reason.
>
> Regards,
> Ken
>
>
___

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


QuickTime Player - like application

2011-05-11 Thread Nick
Hi
Could you please explain me what frameworks/techniques does a
QuickTime Player use to achieve the looks it has now?

So far my GUI building experiences were limited with Interface
Builder'ed gray "static" windows.

How to force the window to make its titlebar/playback control bar
disappear, when the mouse is not over the window?
How to change the color of the window/titlebar?
how to make a control panel (with play/pause/stop buttons) that can
slide only within the main window that's being displayed?
how to make such a customized control buttons? (they look very
different from default default mac os buttons
how to make the window resize preserving a specific aspect ratio?

Sorry if my questions seem naive, i am a beginner in cocoa development :)
Could you please point what guides/references (the names) to look at
to make such things?
Thank you!
___

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


prevent multiple instances of a program

2011-05-11 Thread Martin Batholdy
Hi,

My program consists of a menu item and is NSUIagent - so it is hidden in the 
Mac OS app-bar.

Now what surprises me is that I am able to open several instances of this 
program.
Every time I click on the app-file a new symbol appears and I have a new 
instance of my program running.

How can I prevent this?
(so that system-wide you can only have one instance of the program running)

Is there a build-option in xCode for this?


thanks!___

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: prevent multiple instances of a program

2011-05-11 Thread Dave DeLong
There are a bunch of ways to do this, but the general principle is that when an 
instance of the app starts, it makes its presence known somehow (touching a 
file, broadcasting a distributed notification, vending a distributed object, 
etc).  Then when a second instance starts, it tries to find a previous instance 
(looking for the file, broadcasting a distributed notification and waiting for 
a response, connecting to a distributed object, etc).  If it finds one, it 
kills itself.

Dave

On May 11, 2011, at 2:02 PM, Martin Batholdy wrote:

> Hi,
> 
> My program consists of a menu item and is NSUIagent - so it is hidden in the 
> Mac OS app-bar.
> 
> Now what surprises me is that I am able to open several instances of this 
> program.
> Every time I click on the app-file a new symbol appears and I have a new 
> instance of my program running.
> 
> How can I prevent this?
> (so that system-wide you can only have one instance of the program running)
> 
> Is there a build-option in xCode for this?
> 
> 
> thanks!___
> 
> 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/davedelong%40me.com
> 
> This email sent to davedel...@me.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: QuickTime Player - like application

2011-05-11 Thread Ken Thomases
On May 11, 2011, at 3:25 PM, Nick wrote:

> Could you please explain me what frameworks/techniques does a
> QuickTime Player use to achieve the looks it has now?

Sadly, Apple sometimes implements GUIs in their own apps that are not easily 
reproducible with supported APIs.  Sometimes that's a prelude to them making 
those changes generally available, sometimes not.


> How to force the window to make its titlebar/playback control bar
> disappear, when the mouse is not over the window?
> How to change the color of the window/titlebar?

The QuickTime Player almost certainly is implemented as a borderless window.  
The title bar that it shows is manually implemented as a view or layer within 
the window.  It's not a real title bar, it just recreates the behavior and (to 
some extent) the appearance of one.

You might find the +[NSWindow standardWindowButton:forStyleMask:] method useful 
for obtaining the standard buttons that you can put into your own view 
hierarchy to at least get that part to look and behave correctly.

> how to make a control panel (with play/pause/stop buttons) that can
> slide only within the main window that's being displayed?

I answered this one before.  I would guess that QuickTime Player is using 
either a layer-backed view hierarchy or even just a layer-hosting view (with a 
hierarchy of layers but not subviews).  You would have to manually move the 
view or layer in response to mouse drags.  The View Programming Guide describes 
techniques for handling mouse drags in your custom views.

> how to make such a customized control buttons? (they look very
> different from default default mac os buttons

See the Control and Cell Programming Topics for Cocoa.  Basically, you can make 
a custom view or control (a control is just a special kind of view) that draws 
itself however you like and responds to events however you like.

> how to make the window resize preserving a specific aspect ratio?

See -[NSWindow setContentAspectRatio:].  Did you search the docs at all before 
asking?


> Sorry if my questions seem naive, i am a beginner in cocoa development :)
> Could you please point what guides/references (the names) to look at
> to make such things?

There is not going to be a step-by-step guide to do any possible GUI.  There 
can only be general guides to the features available within the API, and you'll 
have to figure out how to put those features together to make the GUI you 
envision.  Each class lists conceptual documentation in its overview.  You 
should carefully read both the class reference and the associated conceptual 
documentation.  At a minimum, that includes the Window Programming Guide and 
the View Programming Guide.  For a GUI which uses Core Animation, there's the 
Core Animation Programming Guide, of course.

In general, you might go to the Reference Library and pick the User Experience 
or Graphics & Animation topics on the left, sort by resource type, and then 
read the Getting Started resources, then scan the list of Guides to see which 
you think may apply to your question and read those.
http://developer.apple.com/library/mac/navigation/#section=Topics&topic=User%20Experience
http://developer.apple.com/library/mac/navigation/#section=Topics&topic=Graphics%20%26amp%3B%20Animation

Regards,
Ken

___

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: Extending NSTextStorage

2011-05-11 Thread Martin Wierschin
> I try to subclass NSTextStorage and use it in text view
...
> So I try to use delegate, to handle all needed events with same functionality:

Although it might be natural to say that your MyTextStorage class "delegates" 
storage to an NSMutableAttributedString, it's not a good word to use here, 
because in Cocoa a delegate is something more specific. Normally a delegate is 
a weak/unretained reference to some kind of owning/controller object that 
customizes behavior, see:

http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW19

> What I need to do to extend this class ?

Your subclass (as shown) can't work because it hasn't overridden all the 
primitive methods. You also need to implement 
attributesAtIndex:effectiveRange:. See:

http://developer.apple.com/library/mac/documentation/cocoa/Conceptual/TextStorageLayer/Tasks/Subclassing.html#//apple_ref/doc/uid/2926-CJBBIAAF

However, from your error:

> An uncaught exception was raised
> *** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) 
> beyond array bounds (0)
> *** Terminating app due to uncaught exception 'NSRangeException', reason: 
> '*** NSRunStorage, _NSBlockNumberForIndex(): index (18446744073709551615) 
> beyond array bounds (0)'

That looks like an exception raised by the layout manager. You might have other 
problems with your code. I'd use a stock NSTextStorage first and make sure 
everything is working.

~Martin

___

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: QuickTime Player - like application

2011-05-11 Thread John Pannell
Hi Nick-

These things are all possible, but none of it comes for free... you'll need to 
draw your window contents yourself.  To start with, you'll need a "transparent" 
window:

http://www.google.com/search?q=NSBorderlessWindowMask

Also look at Apple's RoundTransparentWindow sample code:

http://developer.apple.com/library/mac/#samplecode/RoundTransparentWindow/Introduction/Intro.html

But wait, there's more...

> How to force the window to make its titlebar/playback control bar
> disappear, when the mouse is not over the window?

http://www.google.com/search?client=safari&rls=en&q=cocoa+mouse+tracking

You'll need to track the mouse in the main content view of the window, and draw 
your UI (or not) as the mouse enters and exits.

> How to change the color of the window/titlebar?

You'll need to draw this view yourself.  There are many different ways to draw 
in a view; I used CoreGraphics/Quartz to draw the borders, rounded corners, 
etc. and CGContextDrawTiledImage to draw the background of the "toolbar".  Be 
attentive: there are transparency effects around the edges of windows; use 
Pixie to examine a standard OS X window over a variety of backgrounds.  Also 
note - you'll need your drawing routine to draw differently for windows that 
are foreground/background.

http://www.google.com/search?client=safari&rls=en&q=NSView+drawing

> how to make a control panel (with play/pause/stop buttons) that can
> slide only within the main window that's being displayed?

I would make another transparent window with the controls.  Listen to the 
windowWillMove: delegate method in your controller to prevent unwanted 
movement.  You'll need to draw your own controls (a common theme in this 
endeavor).

> how to make such a customized control buttons? (they look very
> different from default default mac os buttons

You can get the "stoplight" buttons via standardWindowButton:forStyleMask: and 
place these into your view hierarchy.  These may not look right with the 
background you're drawing; if that is the case, you'll need to draw your own 
buttons.  If you *do* use those buttons, I should warn you that the only way 
I've found to duplicate OS X's mouse over behavior is to employ a private 
method.

Any other buttons or controls are on your own.  I'll also note you'll need to 
draw the window title correctly (i.e. centered in window with proper shadow).

> how to make the window resize preserving a specific aspect ratio?

Listen to the delegate method - (NSSize)windowWillResize:(NSWindow *)sender 
toSize:(NSSize)proposedFrameSize in your controller and only return sizes that 
match your desired aspect ratio.

> 
> Sorry if my questions seem naive, i am a beginner in cocoa development :)

I've never been one to try to talk a beginner out of things... it can be a 
great way to learn a lot.  I would note a few potential pitfalls before you 
launch down this path:

1.  As mentioned, it will be a lot of work to re-invent this wheel - Apple 
provides a very good window drawing framework for free.  Could your development 
time be better spent on something else?
2.  If you diverge too far from the standard UI, you will run the risk of 
getting denied while trying to get your app in the App Store.  From the 
approval guidelines:
6. User interface
• 6.1 Apps must comply with all terms and conditions explained in the 
Apple Macintosh Human Interface Guidelines
• 6.2 Apps that look similar to Apple Products or apps bundled on the 
Mac, including the Finder, iChat, iTunes, and Dashboard, will be rejected
• 6.3 Apps that do not use system provided items, such as buttons and 
icons, correctly and as described in the Apple Macintosh Human Interface 
Guidelines will be rejected
• 6.4 Apple and our customers place a high value on simple, refined, 
creative, well thought through interfaces. They take more work but are worth 
it. Apple sets a high bar. If your user interface is complex or less than very 
good it may be rejected
• 6.5 Apps that change the native user interface elements or behaviors 
of Mac OS X will be rejected

> Could you please point what guides/references (the names) to look at
> to make such things?
> Thank you!

Good Luck!

John


John Pannell
http://www.positivespinmedia.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: prevent multiple instances of a program

2011-05-11 Thread Tito Ciuro
Hi Martin,

One way to do it is via flock():

http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man2/flock.2.html

-- Tito

On May 11, 2011, at 6:04 PM, Dave DeLong wrote:

> There are a bunch of ways to do this, but the general principle is that when 
> an instance of the app starts, it makes its presence known somehow (touching 
> a file, broadcasting a distributed notification, vending a distributed 
> object, etc).  Then when a second instance starts, it tries to find a 
> previous instance (looking for the file, broadcasting a distributed 
> notification and waiting for a response, connecting to a distributed object, 
> etc).  If it finds one, it kills itself.
> 
> Dave
> 
> On May 11, 2011, at 2:02 PM, Martin Batholdy wrote:
> 
>> Hi,
>> 
>> My program consists of a menu item and is NSUIagent - so it is hidden in the 
>> Mac OS app-bar.
>> 
>> Now what surprises me is that I am able to open several instances of this 
>> program.
>> Every time I click on the app-file a new symbol appears and I have a new 
>> instance of my program running.
>> 
>> How can I prevent this?
>> (so that system-wide you can only have one instance of the program running)
>> 
>> Is there a build-option in xCode for this?
>> 
>> 
>> thanks!___
>> 
>> 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/davedelong%40me.com
>> 
>> This email sent to davedel...@me.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/tciuro%40mac.com
> 
> This email sent to tci...@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


Re: prevent multiple instances of a program

2011-05-11 Thread Ken Thomases
On May 11, 2011, at 4:02 PM, Martin Batholdy wrote:

> My program consists of a menu item and is NSUIagent - so it is hidden in the 
> Mac OS app-bar.

I'm not familiar with "NSUIagent" and search of the docs don't produce any 
hits.  Did you mean LSUIElement?  I also assume that "menu item" refers to a 
status item and that "Mac OS app-bar" means the Dock.  Using precise 
terminology is necessary for people to be able to help you.

> Now what surprises me is that I am able to open several instances of this 
> program.
> Every time I click on the app-file a new symbol appears and I have a new 
> instance of my program running.

Are you sure you have a new instance rather than just a second status item?  
Does Activity Monitor show two processes for your app?

> How can I prevent this?
> (so that system-wide you can only have one instance of the program running)

You almost certainly mean "session-wide", not "system-wide", since other users 
can be logged in to other sessions via Fast User Switching.

Anyway, this is the default.  Launch Services will not normally launch a second 
instance of your app.  (The Finder uses Launch Services when you double-click 
an icon.)

So, I suspect that you are creating a second status item in response to the 
events and corresponding delegate method calls that occur when your app is 
double-clicked a second time.  In what method are you creating the status item?

Regards,
Ken

___

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


Cocoaheads Lake Forest meeting TONIGHT, 7pm, El Toro library

2011-05-11 Thread Scott Ellsworth
CocoaHeads Lake Forest will be meeting on the second Wednesday of the month.

Please join us TONIGHT from 7pm to 9pm on Wednesday, 5/11.  We will be
meeting at the Orange County Public Library (El Toro) community room, 24672
Raymond Way, Lake Forest, CA 92630

This will be an informal meeting with no set topic.

Our June meeting is currently scheduled for 6/8, during WWDC.  I will be at
WWDC this year; anyone interested in running the meeting should contact me
off-list.

As always, details and the upcoming meeting calendar can be found at the
cocoaheads web site,www.cocoaheads.org.

(Personal note: Google Irvine is hiring again, and there are some open spots
in MTV for Cocoa/ObjC/iOS development.  Ping me or drop by for details.)
___

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 with bound text field in accessory panel

2011-05-11 Thread Gideon King
Hi, I have a text field which is used in a save panel accessory when exporting 
files from my program. It is bound to the user defaults, and has continuous 
updating of values turned on so that if the user presses Return to complete the 
save operation, I still have the current value even though the text field end 
editing is bypassed.

The problem is that if the user types in the text field, and presses Return to 
export their file, and then goes to export again, the text field is displayed 
blank. If they click in the text field, it displays the correct value, but if 
they click in another text field or tab out of the field, it goes blank again. 
I'm guessing that for some reason the field editor knows the value but the cell 
doesn't.

It doesn't seem to affect the values being stored in the user defaults, but is 
very disconcerting for the user.

Has anyone seen this before? Is there a known workaround?

Thanks

Gideon





___

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: Problem with bound text field in accessory panel

2011-05-11 Thread Ken Thomases
On May 11, 2011, at 8:26 PM, Gideon King wrote:

> Hi, I have a text field which is used in a save panel accessory when 
> exporting files from my program. It is bound to the user defaults, and has 
> continuous updating of values turned on so that if the user presses Return to 
> complete the save operation, I still have the current value even though the 
> text field end editing is bypassed.
> 
> The problem is that if the user types in the text field, and presses Return 
> to export their file, and then goes to export again, the text field is 
> displayed blank. If they click in the text field, it displays the correct 
> value, but if they click in another text field or tab out of the field, it 
> goes blank again. I'm guessing that for some reason the field editor knows 
> the value but the cell doesn't.
> 
> It doesn't seem to affect the values being stored in the user defaults, but 
> is very disconcerting for the user.
> 
> Has anyone seen this before? Is there a known workaround?

Just a guess: does the value end up having an embedded newline character in it? 
 Could it be that the text is scrolled up out of view and you're only seeing 
the second line, which is blank?

Regards,
Ken

___

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: Problem with bound text field in accessory panel

2011-05-11 Thread Kyle Sluder
On Wed, May 11, 2011 at 6:26 PM, Gideon King  wrote:
> Hi, I have a text field which is used in a save panel accessory when 
> exporting files from my program. It is bound to the user defaults, and has 
> continuous updating of values turned on so that if the user presses Return to 
> complete the save operation, I still have the current value even though the 
> text field end editing is bypassed.

The better way to do this might be to call -commitEditing on the user
defaults controller in your panel delegate's -windowWillClose:
implementation.

--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: Problem with bound text field in accessory panel

2011-05-11 Thread Kyle Sluder
On Wed, May 11, 2011 at 7:47 PM, Kyle Sluder  wrote:
> The better way to do this might be to call -commitEditing on the user
> defaults controller in your panel delegate's -windowWillClose:
> implementation.

Er, I meant -windowShouldClose:. But of course I also forgot that you
don't own this panel; you merely get to provide an accessory view.

--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: Problem with bound text field in accessory panel

2011-05-11 Thread Gideon King
Thanks for the suggestions. I have found a solution. I make my file's owner the 
text field's delegate, and then implement the following:

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView 
doCommandBySelector:(SEL)command {
if (command == @selector(insertNewline:)) {
[[control window] makeFirstResponder:nil];
[[control window] performSelector:@selector(ok:) 
withObject:self afterDelay:0];
return YES;
}
return NO;
}



Regards

Gideon

On 12/05/2011, at 12:47 PM, Kyle Sluder wrote:

> On Wed, May 11, 2011 at 6:26 PM, Gideon King  wrote:
>> Hi, I have a text field which is used in a save panel accessory when 
>> exporting files from my program. It is bound to the user defaults, and has 
>> continuous updating of values turned on so that if the user presses Return 
>> to complete the save operation, I still have the current value even though 
>> the text field end editing is bypassed.
> 
> The better way to do this might be to call -commitEditing on the user
> defaults controller in your panel delegate's -windowWillClose:
> implementation.
> 
> --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