Handling NSApplicationDefined events

2009-09-03 Thread McLaughlin, Michael P.
The relevant docs make it clear how to send an NSApplicationDefined NSEvent, e.g., to NSApp, but I cannot find anything, esp. no examples, about how to handle events of this type. I was assuming that it could be done in AppDelegate. Perhaps not -- but I'd really like to see a description and one

Re: Handling NSApplicationDefined events

2009-09-03 Thread McLaughlin, Michael P.
Quincey Morris wrote: >It's straightforward. Subclass NSApplication and override sendEvent: >to test for NSApplicationDefined. > >Don't forget to specify your subclass as the "Principal Class" in your >target's properties. The one example I found like that passed the event on even though it had b

GLSLBasicsCocoaDL sample code

2009-10-05 Thread McLaughlin, Michael P.
I downloaded the sample code http://developer.apple.com/mac/library/samplecode/GLSLBasicsCocoaDL/index.ht ml It built and "ran" under Mac OS 10.5.8 and Xcode 3.1.3. However, the result showed a *black*, rotating object on a not-quite-so-black background. I'm guessing that it should not look lik

Newbie query re checkboxes

2009-10-20 Thread McLaughlin, Michael P.
I have an NSArray (2 x 3) of NSButtonCell in IB. The style is Checkbox. I made the Mode = list so that all might be unchecked. The problem is that my array is behaving like a Radio Group. If I check one any other that is checked turns off. This is not what I want. [No other Mode seems to fix

Textured sheet with tabview

2009-10-22 Thread McLaughlin, Michael P.
Don't know if I did something wrong or this is a bug. [Leopard + Xcode 3.1.3] I thought I would make a (modal) sheet textured because it provided a nice contrast with its non-textured parent window. The sheet contains one tabview and an OK button. Each of four tabs contains a radio group (matri

Terminating subtasks reliably

2010-03-30 Thread McLaughlin, Michael P.
I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks (since threads are not sufficient in this case). Currently, I terminate these subtasks via the app-delegate method -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender This works provided one

Re: Terminating subtasks reliably

2010-03-31 Thread McLaughlin, Michael P.
How does WatchForTermination() do its watching? Is it constantly polling? That would be a performance-killer. On 3/30/10 11:18 PM, "John Harte" wrote: On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote: > I have a Cocoa app (Leopard) which launches several Foundation

Problem with NSData

2010-04-05 Thread McLaughlin, Michael P.
In a Cocoa app targeting Leopard, I am getting a malloc error when using the NSData method - (void)getBytes:(void *)buffer My function is as follows: -(void)getDataSz:(void*)data ofSize:(NSUInteger)sz { NSData *theData = [input readDataOfLength:sz]; [theData getBytes:data]; // <-- no e

Re: Problem with NSData

2010-04-05 Thread McLaughlin, Michael P.
I may be off on an island by myself here but I thought I'd add some more info just in case someone recognizes it and has a useful thought. The error described below occurs because the data I sent through NSFileHandle to NSData (in the subtask) was actually the elements of a vector [just the array,

NSPipe (NSFileHandle) writedata limit?

2010-04-09 Thread McLaughlin, Michael P.
In a Leopard app, I declare an NSPipe with an NSFileHandle attached to it for writing. I have found, by trial and error, that I cannot write more than 65,536 bytes to this pipe which goes to an NSTask. Below that limit works fine. I thought that the limit was supposed to be the unsigned long max

Re: NSPipe (NSFileHandle) writedata limit?

2010-04-09 Thread McLaughlin, Michael P.
I am not getting an error; it just hangs. *** code *** @interface Subtask : NSObject { NSTask *aTask; NSPipe *inPipe, *outPipe; NSFileHandle *sendEnd, *readEnd; NSString *myID; } -(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag:(NSString*)tag; ... @end // in implementatio

Re: NSPipe (NSFileHandle) writedata limit?

2010-04-09 Thread McLaughlin, Michael P.
I would have bet on #2 as well but everything is typed NSUInteger (same as the docs) and, when I NSLog the relevant sizes, sending and receiving, they all come back as 4 bytes. I do not know how to "attach" to the producing process. When NSFileHandle writeData takes off, the Xcode debugger goe

Re: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread McLaughlin, Michael P.
This is turning out to be a lot trickier than I had expected. [I note that there is currently another thread in this list with a similar concern but I'm not sure if our problems are identical.] In my case, I have a main app with an NSArray of subtasks (inheriting from NSObject), initialized then

Re: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread McLaughlin, Michael P.
>Greg Guerin wrote >The fundamental design is "send all data before looking for any >results". This is inherently synchronous, even though two or more >processes are involved. If the subtask is designed to "read all data >before producting any results", then it shouldn't deadlock. However, >if

Timing distributed notifications

2010-05-06 Thread McLaughlin, Michael P.
Is there a recommended way of determining that the currentRunLoop in a subordinate task (executable) is, in fact, running and ready to receive a distributed notification? I have one subtask for each CPU, all launched during the init method of my app. Each subtask responds with a "ready" message e

Re: Timing distributed notifications

2010-05-06 Thread McLaughlin, Michael P.
On 5/6/10 1:57 PM, "Jens Alfke" wrote: > > > On May 6, 2010, at 10:34 AM, McLaughlin, Michael P. wrote: > >> Is there a recommended way of determining that the currentRunLoop in a >> subordinate task (executable) is, in fact, running and ready to >&g

Looking for NSXMLDocument example

2010-07-20 Thread McLaughlin, Michael P.
I have, in the past, used standard (Carbon) documents and windows to find and replace text. Right now, in Cocoa, I do the following: 1. Create an NSXMLDocument from a URL (and show it in a window). 2. Change/replace the string value of one or more nodes. I am looking for a simple code fragment s

Strange window behavior

2011-08-11 Thread McLaughlin, Michael P.
I have a window showing a custom NSView that I move off and on the screen at different times via orderOut and makeKeyAndOrderFront. The window, created in Xcode 4, is set to be fixed from top and left. However, every time it is reshown, it is staggered a bit down and to the right. Is t

Re: Strange window behavior

2011-08-11 Thread McLaughlin, Michael P.
g>> Cc: "cocoa-dev@lists.apple.com<mailto:cocoa-dev@lists.apple.com>" mailto:cocoa-dev@lists.apple.com>> Subject: Re: Strange window behavior On Aug 11, 2011, at 7:51 AM, McLaughlin, Michael P. wrote: The window, created in Xcode 4, is set to be fixed from top and

How disable File/Open command

2011-08-15 Thread McLaughlin, Michael P.
I have a Cocoa document app targeting Snow Leopard. It is, in most respects, a standard document app except that, given an input file, it launches a long, multi-threaded computation. Consequently, it can handle only one input file at a time. For the obvious reasons, I would very much like to

How disable File/Open command -- SOLVED

2011-08-15 Thread McLaughlin, Michael P.
I managed to find this solution shortly after sending a request to this list for help. I show the code below so that future programmers might find this more easily that I did. This solution has not been tested with Lion. [Note: This app does not have a File/New command and does not open an un

How select NSTextField programatically?

2011-12-13 Thread McLaughlin, Michael P.
I have a Cocoa "dialog" with several textfields for numerical input. When the user enters a bad value, I want to select that view programatically along with an NSBeep() so that the user can fix it. What is the best way to select that subview given that I know its tag? Thanks. -- Michael P. Mc

Tab view and radio buttons

2012-02-22 Thread McLaughlin, Michael P.
In Xcode 4.2 (Snow Leopard), I have a window with several tab views. Inside each tab view is a matrix of radio buttons with one preselected as default. I am seeing a problem in which I select a radio button in a view, flip to another tab then back again. When I do this for one of the tabbed vi

Using affine transforms

2011-04-29 Thread McLaughlin, Michael P.
I am writing the drawRect routine for a custom view in which I need to draw a simple X-Y graph, given the data. Desiring to be elegant and up-to-date, I decided that the best (Cocoa) way to do this was to construct a scaling affine transform to change x,y coordinates into view coordinates using C

Unrecognized document type

2011-05-17 Thread McLaughlin, Michael P.
With Xcode 3.2.6, I am getting the (well-discussed) error The OutType type doesn't map to any NSDocumentClass. after theOutDoc = [[NSDocumentController sharedDocumentController] makeUntitledDocumentOfType:@"OutType" error:outError]; I cannot see where I went wrong. My AppDelegate plist sho

How disable Special Characters menu item?

2011-06-06 Thread McLaughlin, Michael P.
I have a Cocoa app (Xcode 3.2.6) which displays text output in a window. This is pure output not meant to be edited by the user. Accordingly, the textfield is marked as not editable or selectable in IB. When the window appears, all of the Edit menu items are disabled except Special Characters

Persistent NSOperation?

2009-12-21 Thread McLaughlin, Michael P.
Could anyone point me to sample code that shows how to implement a persistent NSOperation that could be enqueued repeatedly? Currently, I initialize NSOps just prior to launching but this involves copying large datasets (to avoid R/W contention) and it would be more efficient if I could initialize

Posting notifications

2010-01-25 Thread McLaughlin, Michael P.
Notification Programming Topics for Cocoa states "A notification center delivers notifications to observers synchronously. In other words, when posting a notification, control does not return to the poster until all observers have received *and processed* the notification." [my emphasis] I was wo

Multithread communication

2010-02-03 Thread McLaughlin, Michael P.
In a multithreaded app using NSOperationQueue and targeting Leopard, I am having an inordinate amount of trouble communicating the results of the thread computations to the main thread which acts as an overall coordinator. Specifically, I am getting obscure and sporadic crashes (about 10 percent o

Scope of NSOperations

2010-02-04 Thread McLaughlin, Michael P.
My (Leopard) app needs to create a sequence of NSOperations, often thousands of them, a few at a time. The relevant code is in a setup function that ends with for (k = 0;k < numOps;k++) { solverOp *thisOp = [solverOp new]; [thisOp initWithData:Data]; [opQueue addOperation:thisOp]; } at

Odd NSString behavior

2010-02-24 Thread McLaughlin, Michael P.
This is just a minor glitch but I hate loose ends. I have a Cocoa app as a resource in my MainBundle. If I try to get its executable via the obvious NSString * linrgPath = [myBundle pathForResource: @"linrg2.app/Contents/MacOS/linrg2" ofType: @""]; then linrgPath is nil; However, if I split th

Re: Odd NSString behavior

2010-02-24 Thread McLaughlin, Michael P.
Thank you to all who responded. I like this solution. I also replaced myBundle with [NSBundle mainBundle] directly. On 2/24/10 3:06 PM, "Sherm Pendley" wrote: On Wed, Feb 24, 2010 at 2:30 PM, McLaughlin, Michael P. wrote: > This is just a minor glitch but I hate loose ends.

NSString becoming invalid

2009-06-11 Thread McLaughlin, Michael P.
In an Xcode (3.1.2) Cocoa document app targeting 10.5, I read an NSString from an XML file and store it, eventually, in a C++ struct as NSString *fname; This works most of the time but, sporadically, I get a BAD_ACCESS crash with an indication that fname has become invalid. The only explanation

How refresh window title

2009-08-04 Thread McLaughlin, Michael P.
I know this is supposed to be trivial but none of the permutations I've tried have worked [Xcode 3.1.3]. My current incarnation is as follows: -(void)doShowHide:(BOOL)show time:(short)t { NSWindow *dispWindow = [dispDoc windowForSheet]; NSString *suffix = [NSString stringWithFormat:@": t =

Re: How refresh window title -- SOLVED

2009-08-04 Thread McLaughlin, Michael P.
Found the problem. It did not reside in the code below. Sorry for the waste of bandwidth :-( * I know this is supposed to be trivial but none of the permutations I've tried have worked [Xcode 3.1.3]. My current incarnation is as follows: -(void)doShowHide:(BOOL)show time:(short)t { NSW

Newbie query re multithreading

2009-08-18 Thread McLaughlin, Michael P.
I am converting a Carbon app to Cocoa (where I'm a newbie). The Carbon app was multithreaded and heavily dependent on cblas and clapack. It worked well and was fully twice as fast with 2 CPUs as with 1. However, the code was becoming increasingly obsolete. I now have a Cocoa [ObjectiveC++] vers

Re: Newbie query re multithreading

2009-08-18 Thread McLaughlin, Michael P.
On 8/18/09 1:46 PM, "Bill Bumgarner" wrote: > On Aug 18, 2009, at 10:19 AM, McLaughlin, Michael P. wrote: > >> On 8/18/09 11:34 AM, "Bill Bumgarner" wrote: >> >>> On Aug 18, 2009, at 7:25 AM, McLaughlin, Michael P. wrote: >>> >>

Synchronizing NSWindow updates with threads

2009-08-25 Thread McLaughlin, Michael P.
I have an NSOperation app (simulation) executing one timestep at a time. The threads are working fairly well but the running output is supposed to be drawn as a color-coded map every 10 timesteps. It seems that a window update is a low priority task because my threads are running and continually s

NSOperationQueue emptying

2009-08-27 Thread McLaughlin, Michael P.
I'm wondering about the timing of NSOperationQueue emptying. In my Objective-C++ (Leopard) app, I have one opQueue of operations and the very last thing each operation does is enqueue the results of a computation back to the main thread. NSPointerArray *ptr = [NSPointerArray pointerArrayWithStron

NSBeep() is way too soft!

2010-08-12 Thread McLaughlin, Michael P.
I have a new Mac Pro which is perfectly OK except that the NSBeep() function in my code (OS 10.6.4, Xcode 3.2.3) produces a beep (the default) that is almost too soft to hear. Other sounds through the internal speaker are fine. Is this a bug or a feature? Thanks. -- Mike McLaughlin __

Test for launched from (Apple)Script?

2010-11-10 Thread McLaughlin, Michael P.
Is there any standard way for a Cocoa app to test whether it was launched from a script, esp. AppleScript? I would like to set a flag to disable dialogs so that users could run the app in (faceless) batch mode. Thanks. -- Mike McLaughlin ___ Cocoa-d

Re: Cocoa-dev Digest, Vol 7, Issue 1044

2010-11-10 Thread McLaughlin, Michael P.
> On 10 Nov 2010, Mitchell, Jonathan wrote: >> On 10 Nov 2010, at 18:34, McLaughlin, Michael P. wrote: >> >> Is there any standard way for a Cocoa app to test whether it was launched >> from a script, esp. AppleScript? I would like to set a flag to disable >> di

How send XML data to document window?

2011-01-25 Thread McLaughlin, Michael P.
In my app, I read an XML file, init an NSXMLDocument and also display the file contents in an NSTextField in a document window. The user can then change parts of the XML via several dialogs. The XML data is eventually sent to subprocesses for computation. The NSTextField is set to non-editable b

MPProcessing in Lion

2012-05-14 Thread McLaughlin, Michael P.
This past weekend I tried compiling my Snow Leopard Cocoa app in Lion (Xcode 4.3) just to make sure all was OK. I got two warnings stating that MPProcessorsScheduled and MPCreateCriticalRegion were deprecated in Lion but the relevant Lion docs did not say what they should to be replaced with.

Drag-and-drop crashes

2012-07-30 Thread McLaughlin, Michael P.
I have a Mac OS app that worked fine in Snow Leopard. In moving up recently to Lion, I also moved up to Xcode 4.4 and recompiled the app, targeting 10.6 but without otherwise changing the source code. I got two problems when running the resulting app under Lion. I fixed the first problem by

Open menu crashes Cocoa app targeting SL

2012-08-03 Thread McLaughlin, Michael P.
My app, created in Lion but targeting SL seems to work fine except that, when actually run in Snow Leopard, it crashes whenever Open or Open Recent is selected. The crash log gives 0 com.apple.AppKit 0x7fff885e49de -[NSImage _allocAuxiliaryStorage] + 158 1 com.apple.AppKi

Newbie query re notifications

2009-03-06 Thread McLaughlin, Michael P.
I have been using notifications in a simple document app that processes data from a datafile. This app has a document window and an appDelegate, both of which appear in IB with the proper connections. The document can successfully send notifications to the appDelegate and the latter can send noti

Re: Newbie query re notifications -- SOLVED

2009-03-06 Thread McLaughlin, Michael P.
Error was of the typo variety. Too embarrassing to describe further :-( -- Mike McLaughlin ___ 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-d

Notifications and timing

2009-03-12 Thread McLaughlin, Michael P.
I have a "global" gFlags variable (unsigned long long) and several objects that need a pointer to it. I fill one such pointer, and reinit gFlags, via the following code: if (flags == nil) { flagPtr *flgH = &flags; NSData *flgsDatum = [[NSData alloc] initWithBytesNoCopy:flgH length:siz

How remove a clip path?

2009-05-05 Thread McLaughlin, Michael P.
In a custom NSBezierView, I fill the view with a background color then set a clip path that will eventually be drawn as a map. I do this so that I can color-code the map (in a complicated way) without "going outside the lines". If I then draw the map, external boundaries are drawn as half-width l

How remove a clip path? SOLVED

2009-05-05 Thread McLaughlin, Michael P.
Naturally, I came up with a solution two minutes after posting my query to this list :-( My solution is [[NSBezierPath bezierPathWithRect:rect] setClip]; where rect is the viewRect. This works for me. It might not be the best solution in all cases. *** Original post *** In a custom NSBezierV

Disabling menu items

2009-05-15 Thread McLaughlin, Michael P.
In a Cocoa Document project (latest Xcode), I want to have only one document open at a time. I thought that I could do this by subclassing NSDocumentController but I have been only partially successful. For instance, just as a test, the subclass code contains -(BOOL)validateUserInterfaceItem:(id

Re: Disabling menu items

2009-05-15 Thread McLaughlin, Michael P.
s menu event although I was aware that openRecentDocument: was not in the corresponding API. openRecentDocument: is so far the only method I have seen that comes close to being what I was looking for. I'm still looking. > On 15 May 2009, at 16:01, McLaughlin, Michael P. wrote: > >

Traversing an NSXML subtree

2009-05-27 Thread McLaughlin, Michael P.
In reviewing the NSXML documents, I found no really simple way to traverse a subtree of an NSXMLDocument. That is, traverse from the root until you hit the node with the right name then pretend that that node is the root of a smaller tree and traverse just the latter. [Everything I found talked o

Re: Traversing an NSXML subtree

2009-05-28 Thread McLaughlin, Michael P.
On 5/27/09 5:02 PM, "Keith Duncan" wrote: >> Could someone clue me in as to the preferred method to do a >> subtraversal? > > Have you looked at XPath, it will save you from having to enumerate > and perform element-name string comparisons. > > Keith > Yes. I looked at that but 1. My tree is

Re: Cocoa-dev Digest, Vol 6, Issue 794

2009-05-28 Thread McLaughlin, Michael P.
On 5/27/09 6:42 PM, "Greg Guerin wrote: >> In reviewing the NSXML documents, I found no really simple way to >> traverse a >> subtree of an NSXMLDocument. That is, traverse from the root until >> you hit >> the node with the right name then pretend that that node is the >> root of a >> smaller t

Horizontol scroller not enabled in IB

2014-01-30 Thread McLaughlin, Michael P.
Using Xcode 5.0.2 in Mac OS 10.9.1, I created a Cocoa document app, replacing the templated text field with a textview. After making the necessary connections, everything worked as intended. I then went into Document.xib and checked Show Horizontal Scroller in the Bordered scroll view (in addi

When to call super

2014-08-12 Thread McLaughlin, Michael P.
Is there a sure-fire way to know when it is necessary to call super in an override? Sample code shows that calling super is necessary for methods such as -(id)init - (void)windowControllerDidLoadNib but not for (NSData *)dataOfType (BOOL)readFromData How can you know for sure? This q