Re: Coding double modifier global hotkeys?

2010-01-24 Thread Sumner Trammell
Thanks Eric. I'm not surprised.

It seems that interpreting the events produced by the rapid double
press/release of a modifier key is a way to do double modifier global
hotkey detection...?


-s



On Sun, Jan 24, 2010 at 12:52 PM, Eric Schlegel  wrote:
>
> On Jan 24, 2010, at 9:17 AM, Sumner Trammell wrote:
>
>> This code does a fine job of setting up standard "modifier key +
>> regular key" global hotkeys, but I can't figure out how to do double
>> modifier hotkeys. For example:
>>
>> command-command
>> option-option
>
> The Carbon hotkey API doesn't support these types of combinations. Those apps 
> you mentioned are detecting these combinations in some other fashion.
>
> -eric
>
>
___

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


Coding double modifier global hotkeys?

2010-01-24 Thread Sumner Trammell
Hi,

I've been playing with code to create global hotkeys. I found some
sample code here:

http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily

(To my dismay, these things require Carbon knowledge, but thanks to
the sample code, it seems that I can once again get away with knowing
almost nothing of the Carbon APIs.)

This code does a fine job of setting up standard "modifier key +
regular key" global hotkeys, but I can't figure out how to do double
modifier hotkeys. For example:

command-command
option-option
etc.


OmniFocus, Quicksilver and LaunchBar, to name a few, support double
modifier global hotkeys.


Can anyone point me to some documentation or give me hints on how to
create double modifier global hotkeys? The following didn't work,
fwiw:


error = RegisterEventHotKey(cmdKey, cmdKey, gMyHotKeyID,
GetApplicationEventTarget(), 0, &gMyHotKeyRef);





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


Tabbed preference panels

2008-08-22 Thread Sumner Trammell
Hi, I'm working on a preferences panel. I want to build a compound
panel like the kind seen in most mainstream apps today: a toolbar on
top with "tabbed" view switching. The panel changes its appearance
depending on which 32x32 toolbar icon you have selected.

I'm not sure where to start. Looking for examples, I've looked in
Safari's app bundle resources dir, and I see that Safari uses separate
nibs per preferences tab.  When I open one of these nibs, I see a
window object, and that window object has the preference tab's layout.
 Pretty straightforward. Of course, Safari is not open source, so I
can't go any further and see how this design works.

Looking at the source for Transmission, I see they've taken a
different approach, which is to have one PrefsWindow.xib, and in that
xib, a number of View objects, one for each tab. Open the view object
representing a particular preference tab, and you see its layout. I
have not studied the Transmission source yet to see how they make it
all work.

So we have at least 2 accepted ways of doing the tabbed preference
panel thing. But I'd like a better understanding of the hows and why's
overall. Can anyone point me to some Cocoa programming guide docs, or
programming topics docs, on tabbed preference panels? (Are they even
called "tabbed preference panels?")


Thanks,
-s
___

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 [EMAIL PROTECTED]


Window controllers, code obfuscation

2008-08-19 Thread Sumner Trammell
Hi, I'm trying to decipher someone else's code who is no longer
available.  He did something that I think I can simplify, but I first
want to make sure I'm not being completely wrong-headed about what I'm
looking at.



He does the following in his MyDocument.m file:

- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{   

NSWindow* window = [[[self windowControllers] objectAtIndex:0] window];
[[window windowController] setShouldCascadeWindows:NO];

.
.
.
}


In English:

He grabs a reference to the array of window controllers from the
document object.
He grabs the first window controller from that array.
He grabs the window from that window controller.
He sends a message, setShouldCascadeWindows:NO, to that window's
window controller.



Unless I'm being completely stupid about this, he could have done this, right?

[[[self windowControllers] objectAtIndex:0] setShouldCascadeWindows:NO];


Or better yet, this?

[aController setShouldCascadeWindows:NO];



Thanks,
-s
___

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 [EMAIL PROTECTED]


What is Core Foundation, and other terminology/history questions.

2008-08-17 Thread Sumner Trammell
Hi, can someone explain to me the philosophy/principles behind Core
Foundation? I'm just having a hard time seeing the overall
relationship between Carbon, Core Foundation, and Cocoa.


A few (stupid) questions I have are:

+ Why was Core Foundation invented?

+ What did developers use BEFORE Core Foundation, back in the NEXTSTEP
days? There was no Core Foundation back then, correct? Everything was
pure Obj-C/Cocoa?

+ When Apple and NeXT merged, the Carbon and Cocoa (before they got
those names) APIs needed merging? And so a common base was created?
And it is Core Foundation?






Below is my semi-understanding (that's why they're questions, not
statements) of things, and I would greatly appreciate corrections to
it:

+ Cocoa is the current evolution of NEXTSTEP and (still) based on Objective-C?

+ Carbon is the current, but deprecated evolution of the C++ based
APIs from Mac OS 8 and 9?






The rest are shots in the dark. Please correct me:

+ Core Foundation is C-based glue code between Carbon and Cocoa?

+ Core Foundation is C-based glue code between Carbon and the underlying OS?

+ Core Foundation is C-based glue code that allows Carbon apps to have
Aqua GUIs?

+ Core Foundation is   I'm asking.



All of this may seem like idle chatter to the experts, but answering
them goes a long way towards understanding what the docs are talking
about, and what others mean when discussing OS X development.

Thanks,

-s
___

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 [EMAIL PROTECTED]


Why won't Gmail cooperate with authentication delegate methods? (Gmail RSS feeds do.)

2008-08-13 Thread Sumner Trammell
(I realize that this is bordering on a Google API question, but there
is some Cocoa content.)



Hi. One can whip up a WebKit/Cocoa app, aim it at a Gmail URL like this:

https://www.google.com/accounts/ServiceLoginAuth?continue=http://mail.google.com/gmail&service=mail&Email=YOUR_LOGIN&Passwd=YOUR_PASSWORD&null=Sign+in

and get automatically logged into her Gmail account.  Pretty cool.







Even cooler, in my opinion, is implementing this delegate method:

- (void)webView:(WebView *)aSender
   resource:(id)anIdentifier
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)aChallenge
 fromDataSource:(WebDataSource *)aDataSource

(Pages 20-21 of the URL Loading System documentation have the details.)

So now, when you aim your app at the Gmail RSS feed URL:

https://mail.google.com/mail/feed/atom


you are authenticated automatically as well.







The second case has me wishing there were a special URL for the first
case that used standard authentication. (And thus would work with
authentication delegate methods.)

I tried the obvious, https://mail.google.com/mail, and that doesn't
work.  I'm still presented with the Gmail login form screen.

Does anyone know if a special URL exists for Gmail that uses standard
SSLv3 authentication like the Gmail RSS feed URL does?





Thanks,
-s
___

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 [EMAIL PROTECTED]


When the getter returns a BOOL, is "is" the preferred prefix?

2008-08-08 Thread Sumner Trammell
Hi, I have another "What's the idiom?" question.

We know that Cocoa strongly suggests using setFoo and foo for setters
and getters.

Sometimes I see setters and getters using the idiom setFoo and isFoo.
For example, in NSToolbar, you have setVisible and isVisible.

When the getter returns a BOOL, is "is" the preferred prefix?

Side question: do KVC and KVO still work when the getter is prefixed with "is" ?


Thanks,

-s
___

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 [EMAIL PROTECTED]


Re: Control-dragging from menu item in MainMenu.nib to File's Owner object in MyDocument.nib

2008-08-08 Thread Sumner Trammell
Thanks Shawn.  Another case of "Oh, now I know when to use that
mechanism I've heard so much about."


-s



On Fri, Aug 8, 2008 at 1:02 PM, Shawn Erickson <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 8, 2008 at 8:52 AM, Sumner Trammell
> <[EMAIL PROTECTED]> wrote:
>> Hi, my document-based app, created from the Xcode document-based app
>> template, now needs a new item added to its File menu.
>>
>> Menu items are, of course, in MainMenu.nib, and the rest of the app's
>> widgets, like the main window, etc. are in MyDocument.nib.
>>
>> I can't control-drag from my new menu item in MainMenu.nib to the
>> File's Owner object in MyDocument.nib. It makes sense to me that I
>> can't, but it never occurred to me that I couldn't.  Does that make
>> sense?
>>
>> I'm not sure what to do to reshape my design.  Would this be a prime
>> reason to subclass NSDocumentController?  Or am I just missing
>> something in IB?
>
> First Responder and the Responder Chain... learn it, live it, love it
>
> <http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_5.html>
> <http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_6.html>
> <http://developer.apple.com/documentation/DeveloperTools/Conceptual/IB_UserGuide/ApplicationBasics/chapter_3_section_2.html#//apple_ref/doc/uid/TP40005344-CH3-SW15>
>
> etc.
>
> -Shawn
>
___

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 [EMAIL PROTECTED]


Re: Does [NSApp setApplicationIconImage] leak memory?

2008-08-08 Thread Sumner Trammell
Ok, stupid question time.

1. Is the need for the autorelease pool because of the use of
setApplicationIconImage, or because of the array that is being used in
conjunction with setApplicationIconImage?

2. Would putting the calls to setApplicationIconImage in a class
method also stop the memory leak?


Thanks,

-s





On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg <[EMAIL PROTECTED]> wrote:
> On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan <[EMAIL PROTECTED]>
> said:
>>Hi all,
>>
>>Before I file a bug report against this, I just thought I'd check I'm
>>not being monumentally stupid first!
>>
>>I'm trying to animate my app's Dock icon, which works fine and looks
>>great, but unfortunately, it appears to leak memory like crazy.
>>Every time I call [NSApp setApplicationIconImage:(NSImage *)] and
>>pass it pointer to an existing image, it leaks more memory.
>
> Wrap each call to setApplicationIconImage in an autorelease pool creation
> and release, like this:
>
>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>[NSApp setApplicationIconImage: whatever];
>[pool release];
>
> I think you'll find that solves the problem.
>
> m.
> --
> matt neuburg, phd = [EMAIL PROTECTED], 
> A fool + a tool + an autorelease pool = cool!
> One of the 2007 MacTech Top 25: 
> AppleScript: the Definitive Guide - Second Edition!
> 
>
>
>
> ___
>
> 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/sumner.trammell%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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 [EMAIL PROTECTED]


Re: How do I get those 1 pixel black lines into my app window?

2008-08-08 Thread Sumner Trammell
Thanks guys, this works beautifully.

-s



On Thu, Aug 7, 2008 at 4:20 PM, Ken Ferry <[EMAIL PROTECTED]> wrote:
> Hi Sumner,
>
> Check out the discussion of -[NSWindow
> setContentBorderThickness:forEdge:] in the AppKit release notes.
> Here's some of it, but it's probably better to read it in context.
>
> "The behavior of -setContentBorderThickness:forEdge:NSMinYEdge and
> -setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge for
> non-textured windows will do the following: The top gradient will be
> repeated in the bottom border, separator lines will be drawn between
> the content and the bottom border, and the bottom corner will be
> rounded. Other methods on non-textured windows or unused edges will
> return 0.0 or YES."
>
> http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSWindow
>
> -Ken
>
> On Thu, Aug 7, 2008 at 11:20 AM, Sumner Trammell
> <[EMAIL PROTECTED]> wrote:
>> Hi, I've notced that in most apps, at the top and bottom, there is a 1
>> pixel black line separating the gray window
>> from the (usually) white content.
>>
>> This looks better than stock, which of course is why everybody and
>> Apple seems to be doing it. What is the canonical way to do this?  Are
>> people using horizontal line NSBox objects to create these?  That
>> seems like a kludge.  They also make for Illegal Geometry complaints
>> from Interface Builder.
>>
>>
>> Thanks,
>> -s
>> ___
>>
>> 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/kenferry%40gmail.com
>>
>> This email sent to [EMAIL PROTECTED]
>>
>
___

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 [EMAIL PROTECTED]


Control-dragging from menu item in MainMenu.nib to File's Owner object in MyDocument.nib

2008-08-08 Thread Sumner Trammell
Hi, my document-based app, created from the Xcode document-based app
template, now needs a new item added to its File menu.

Menu items are, of course, in MainMenu.nib, and the rest of the app's
widgets, like the main window, etc. are in MyDocument.nib.

I can't control-drag from my new menu item in MainMenu.nib to the
File's Owner object in MyDocument.nib. It makes sense to me that I
can't, but it never occurred to me that I couldn't.  Does that make
sense?

I'm not sure what to do to reshape my design.  Would this be a prime
reason to subclass NSDocumentController?  Or am I just missing
something in IB?

Thanks,
-s
___

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 [EMAIL PROTECTED]


How do I get those 1 pixel black lines into my app window?

2008-08-07 Thread Sumner Trammell
Hi, I've notced that in most apps, at the top and bottom, there is a 1
pixel black line separating the gray window
from the (usually) white content.

This looks better than stock, which of course is why everybody and
Apple seems to be doing it. What is the canonical way to do this?  Are
people using horizontal line NSBox objects to create these?  That
seems like a kludge.  They also make for Illegal Geometry complaints
from Interface Builder.


Thanks,
-s
___

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 [EMAIL PROTECTED]


Re: Making child windows move with their parents

2008-07-31 Thread Sumner Trammell
That should be:

I added the addChildWindow:ordered: call to webView:createWebViewWithRequest:


and things work perfectly.



-s





On Thu, Jul 31, 2008 at 10:55 PM, Sumner Trammell
<[EMAIL PROTECTED]> wrote:
> I've solved it, finally.  My mistake was not realizing that the
> (WebView *)sender being passsed into webViewShow: is the CHILD
> webView.  I needed to act on the parent webView before things got that
> far.
>
> I added the call to addChildWindow:ordered: and things work perfectly.
>  Move the main window, and the popup moves right with it.
>
>
>
> - (WebView *)webView:(WebView *)aSender
> createWebViewWithRequest:(NSURLRequest *)aRequest {
>
>MyDocument *theDocument = [[NSDocumentController
> sharedDocumentController] openUntitledDocumentOfType:@"MyDocumentType"
> display:YES];
>[[[theDocument webView] mainFrame] loadRequest:aRequest];
>
>//put the parent child stuff here
>[[aSender window] addChildWindow:[[theDocument webView] window]
> ordered:NSWindowAbove];
>
>return [theDocument webView];
> }
>
>
> aSender is the parent webView that is passed into the method
> [aSender window] is the parent webView's window
>
> theDocument is the child document object
> [[theDocument webView] window] is the child document's webView's window
>
>
>
>
>
> On Thu, Jul 31, 2008 at 1:43 PM, Sumner Trammell
> <[EMAIL PROTECTED]> wrote:
>> Nope.  This version crashes as well:
>>
>> [[[self webView] window] addChildWindow:[[theDocument webView] window]
>> ordered:NSWindowAbove];
>>
>>
>>
>> I'm getting something wrong in the way I'm looking at this problem.
>> What am I not seeing?
>>
>>
>>
>> Thanks,
>> -s
>>
>>
>>
>>
>> On Thu, Jul 31, 2008 at 1:01 PM, Sumner Trammell
>> <[EMAIL PROTECTED]> wrote:
>>> Thanks Graham.
>>>
>>> I'm beginning to wonder if this will work at all?  It just occurred to
>>> me that every time I click a popup-type link in my webView, that popup
>>> is itself a new instance of MyDocument.  I don't see how I could add
>>> that popup window as a child of the main window when they are separate
>>> document instances.  I hope I am looking at this wrong.
>>>
>>>
>>> A few sanity checks:
>>>
>>> aSender is the child webView
>>> [aSender window] is the child webView's window
>>> theDocument is the child webView's document
>>> [[theDocument webView] window] is the child webView's document's
>>> window (say that fast!)
>>>
>>> self is the parent document (class MyDocument)
>>> [self webView] is the parent document's webView
>>> [[self webView] window] is the parent document's webView's window
>>>
>>>
>>> In my mind, I want to add the child window to the parent one:
>>>
>>> [[[self webView] window] addChildWindow:[[theDocument webView] window]
>>> ordered:NSWindowAbove];
>>>
>>>
>>> I'll try this shortly.
>>>
>>>
>>> Thanks,
>>> -s
>>>
>>>
>>> On Thu, Jul 31, 2008 at 1:43 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
>>>> NSDocument doesn't implement -window
>>>>
>>>> I think you're getting muddled about what "sender" is and the relationship
>>>> between the document and other objects. Using addChildWindow: should be OK,
>>>> once you've sorted this out.
>>>>
>>>> hth,
>>>>
>>>> Graham
>>>>
>>>> On 31 Jul 2008, at 2:51 pm, Sumner Trammell wrote:
>>>>
>>>>> but it doesn't work.  I get *** -[MyDocument window]: unrecognized
>>>>> selector sent to instance 0x1613ab30 in the run log.
>>>>
>>>>
>>>
>>
>
___

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 [EMAIL PROTECTED]


Re: Making child windows move with their parents

2008-07-31 Thread Sumner Trammell
I've solved it, finally.  My mistake was not realizing that the
(WebView *)sender being passsed into webViewShow: is the CHILD
webView.  I needed to act on the parent webView before things got that
far.

I added the call to addChildWindow:ordered: and things work perfectly.
 Move the main window, and the popup moves right with it.



- (WebView *)webView:(WebView *)aSender
createWebViewWithRequest:(NSURLRequest *)aRequest {

MyDocument *theDocument = [[NSDocumentController
sharedDocumentController] openUntitledDocumentOfType:@"MyDocumentType"
display:YES];
[[[theDocument webView] mainFrame] loadRequest:aRequest];

//put the parent child stuff here
[[aSender window] addChildWindow:[[theDocument webView] window]
ordered:NSWindowAbove];

return [theDocument webView];
}


aSender is the parent webView that is passed into the method
[aSender window] is the parent webView's window

theDocument is the child document object
[[theDocument webView] window] is the child document's webView's window





On Thu, Jul 31, 2008 at 1:43 PM, Sumner Trammell
<[EMAIL PROTECTED]> wrote:
> Nope.  This version crashes as well:
>
> [[[self webView] window] addChildWindow:[[theDocument webView] window]
> ordered:NSWindowAbove];
>
>
>
> I'm getting something wrong in the way I'm looking at this problem.
> What am I not seeing?
>
>
>
> Thanks,
> -s
>
>
>
>
> On Thu, Jul 31, 2008 at 1:01 PM, Sumner Trammell
> <[EMAIL PROTECTED]> wrote:
>> Thanks Graham.
>>
>> I'm beginning to wonder if this will work at all?  It just occurred to
>> me that every time I click a popup-type link in my webView, that popup
>> is itself a new instance of MyDocument.  I don't see how I could add
>> that popup window as a child of the main window when they are separate
>> document instances.  I hope I am looking at this wrong.
>>
>>
>> A few sanity checks:
>>
>> aSender is the child webView
>> [aSender window] is the child webView's window
>> theDocument is the child webView's document
>> [[theDocument webView] window] is the child webView's document's
>> window (say that fast!)
>>
>> self is the parent document (class MyDocument)
>> [self webView] is the parent document's webView
>> [[self webView] window] is the parent document's webView's window
>>
>>
>> In my mind, I want to add the child window to the parent one:
>>
>> [[[self webView] window] addChildWindow:[[theDocument webView] window]
>> ordered:NSWindowAbove];
>>
>>
>> I'll try this shortly.
>>
>>
>> Thanks,
>> -s
>>
>>
>> On Thu, Jul 31, 2008 at 1:43 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
>>> NSDocument doesn't implement -window
>>>
>>> I think you're getting muddled about what "sender" is and the relationship
>>> between the document and other objects. Using addChildWindow: should be OK,
>>> once you've sorted this out.
>>>
>>> hth,
>>>
>>> Graham
>>>
>>> On 31 Jul 2008, at 2:51 pm, Sumner Trammell wrote:
>>>
>>>> but it doesn't work.  I get *** -[MyDocument window]: unrecognized
>>>> selector sent to instance 0x1613ab30 in the run log.
>>>
>>>
>>
>
___

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 [EMAIL PROTECTED]


Re: Making child windows move with their parents

2008-07-31 Thread Sumner Trammell
Nope.  This version crashes as well:

[[[self webView] window] addChildWindow:[[theDocument webView] window]
ordered:NSWindowAbove];



I'm getting something wrong in the way I'm looking at this problem.
What am I not seeing?



Thanks,
-s




On Thu, Jul 31, 2008 at 1:01 PM, Sumner Trammell
<[EMAIL PROTECTED]> wrote:
> Thanks Graham.
>
> I'm beginning to wonder if this will work at all?  It just occurred to
> me that every time I click a popup-type link in my webView, that popup
> is itself a new instance of MyDocument.  I don't see how I could add
> that popup window as a child of the main window when they are separate
> document instances.  I hope I am looking at this wrong.
>
>
> A few sanity checks:
>
> aSender is the child webView
> [aSender window] is the child webView's window
> theDocument is the child webView's document
> [[theDocument webView] window] is the child webView's document's
> window (say that fast!)
>
> self is the parent document (class MyDocument)
> [self webView] is the parent document's webView
> [[self webView] window] is the parent document's webView's window
>
>
> In my mind, I want to add the child window to the parent one:
>
> [[[self webView] window] addChildWindow:[[theDocument webView] window]
> ordered:NSWindowAbove];
>
>
> I'll try this shortly.
>
>
> Thanks,
> -s
>
>
> On Thu, Jul 31, 2008 at 1:43 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
>> NSDocument doesn't implement -window
>>
>> I think you're getting muddled about what "sender" is and the relationship
>> between the document and other objects. Using addChildWindow: should be OK,
>> once you've sorted this out.
>>
>> hth,
>>
>> Graham
>>
>> On 31 Jul 2008, at 2:51 pm, Sumner Trammell wrote:
>>
>>> but it doesn't work.  I get *** -[MyDocument window]: unrecognized
>>> selector sent to instance 0x1613ab30 in the run log.
>>
>>
>
___

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 [EMAIL PROTECTED]


Re: Making child windows move with their parents

2008-07-31 Thread Sumner Trammell
Thanks Jens.

I'll change that config.  I did see the warning, but figured I would
run it anyway.

In a document-based app created using the Xcode template, there is in
fact a window outlet on File's Owner, which in this case is of class
MyDocument.  What does that window outlet actually represent?


-s





On Thu, Jul 31, 2008 at 1:45 AM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>
> On 30 Jul '08, at 9:51 PM, Sumner Trammell wrote:
>
>> but it doesn't work.  I get *** -[MyDocument window]: unrecognized
>> selector sent to instance 0x1613ab30 in the run log.
>>
>> aSender is the WebView in the main window.
>> self is the MyDocument object, and it has a window outlet that I can
>> see when I right-click the File's Owner in IB.
>
> Look at your code. You tried to send -window to a MyDocument object, which
> is a subclass of NSDocument:
>
>>[[self window] addChildWindow:[aSender window]
>> ordered:NSWindowAbove];
>
> There is no such method (because documents can have multiple windows, so
> there's no sensible result.)
>
> You must have gotten a warning about this at compile time. *Do not ignore
> such warnings*. They should be treated as error messages because, nearly
> always, they indicate a situation that will throw an exception at runtime,
> causing your app to fail. I recommend turning on the "treat warnings as
> errors" build config checkbox.
>
> —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 [EMAIL PROTECTED]


Re: Making child windows move with their parents

2008-07-31 Thread Sumner Trammell
Thanks Graham.

I'm beginning to wonder if this will work at all?  It just occurred to
me that every time I click a popup-type link in my webView, that popup
is itself a new instance of MyDocument.  I don't see how I could add
that popup window as a child of the main window when they are separate
document instances.  I hope I am looking at this wrong.


A few sanity checks:

aSender is the child webView
[aSender window] is the child webView's window
theDocument is the child webView's document
[[theDocument webView] window] is the child webView's document's
window (say that fast!)

self is the parent document (class MyDocument)
[self webView] is the parent document's webView
[[self webView] window] is the parent document's webView's window


In my mind, I want to add the child window to the parent one:

[[[self webView] window] addChildWindow:[[theDocument webView] window]
ordered:NSWindowAbove];


I'll try this shortly.


Thanks,
-s


On Thu, Jul 31, 2008 at 1:43 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
> NSDocument doesn't implement -window
>
> I think you're getting muddled about what "sender" is and the relationship
> between the document and other objects. Using addChildWindow: should be OK,
> once you've sorted this out.
>
> hth,
>
> Graham
>
> On 31 Jul 2008, at 2:51 pm, Sumner Trammell wrote:
>
>> but it doesn't work.  I get *** -[MyDocument window]: unrecognized
>> selector sent to instance 0x1613ab30 in the run log.
>
>
___

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 [EMAIL PROTECTED]


Making child windows move with their parents

2008-07-30 Thread Sumner Trammell
Hi. In my WebKit-based app, there is an occasional popup window, and
I'm trying to make it so that when you move the main window around,
the popup moves as well.


Here is my typical, vanilla WebView delegate method. In it, new
windows are made visible:

- (void)webViewShow:(WebView *)aSender {
NSDocumentController *theDocumentController =
[NSDocumentController sharedDocumentController];
MyDocument *theDocument = [theDocumentController
documentForWindow:[aSender window]];
[theDocument showWindows];
}



I tried adding this just before the [theDocument showWindows] call:

- (void)addChildWindow:(NSWindow *)childWindow
ordered:(NSWindowOrderingMode)orderingMode


like so:

- (void)webViewShow:(WebView *)aSender {
NSDocumentController *theDocumentController =
[NSDocumentController sharedDocumentController];
MyDocument *theDocument = [theDocumentController
documentForWindow:[aSender window]];

[[self window] addChildWindow:[aSender window] ordered:NSWindowAbove];

[theDocument showWindows];
}




but it doesn't work.  I get *** -[MyDocument window]: unrecognized
selector sent to instance 0x1613ab30 in the run log.

aSender is the WebView in the main window.
self is the MyDocument object, and it has a window outlet that I can
see when I right-click the File's Owner in IB.



It seems to me that I want the new window to be made a child of the
current window. I obviously have something wrong, but I can't figure
out what.

I also tried:

[[[self webView] window] addChildWindow:[aSender window]
ordered:NSWindowAbove];


but that just crashes.




Thanks,
-s
___

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 [EMAIL PROTECTED]


Re: How would you tell WebKit to keep all JavaScript popup windows on top/in front?

2008-07-30 Thread Sumner Trammell
Thanks Rob.

-s


On Wed, Jul 30, 2008 at 3:35 PM, Rob Napier <[EMAIL PROTECTED]> wrote:
> There are likely several ways, but one way is to raise the window's level.
> When you create the window, use [window setLevel:NSFloatingWindowLevel] for
> those windows you want to float.
>
> -Rob
>
> --
> Rob Napier -- Software and Security Consulting -- http://robnapier.net
>
>
>
> On Jul 28, 2008, at 1:58 PM, Sumner Trammell wrote:
>
>> Hi, I've used WebKit to write a small Single-Site Browser that takes
>> you straight to a special section of the company intranet. It works
>> great, but there is one particular link on the page that creates a
>> popup window using JavaScript.  I want this popup to always stay on
>> top. In other words, I don't want the main window to ever hide the
>> popup. I'm not sure how to do this.  How would you tell WebKit to keep
>> all popup windows on top/in front?
>>
>> Thanks,
>> -s
>
___

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 [EMAIL PROTECTED]


Is the WebView inspector buggy in Interface Builder 3.0?

2008-07-30 Thread Sumner Trammell
Hi, is anyone else having problems with the WebView inspector in
Interface Builder 3.0?

I have a window with a WebView on it in MyDocument.nib.

When I open MyDocument.nib, the WebView attributes inspector shows
font sizes of 12 and 12 for default and fixed fonts.  It also shows
Java enabled.


I change the default and fixed font sizes to 16 and 13.

I uncheck the checkbox to disable Java.

I save the nib.

I reopen the nib.

The WebView inspector again shows font sizes of 12 and 12 for default
and fixed fonts, and Java enabled.

I've resorted to setting the params manually in
windowControllerDidLoadNib: like this:

[[webView preferences] setDefaultFixedFontSize:10];
[[webView preferences] setDefaultFontSize:14];
[[webView preferences] setJavaEnabled:NO];



I have also noticed some of the fields/controls in the WebView
inspector changing randomly when I'm in that inspector making changes.

Thanks,
-s
___

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 [EMAIL PROTECTED]


"get" prefixes in Cocoa

2008-07-30 Thread Sumner Trammell
Hi. Cocoa idioms dictate setFoo: and foo: for setters and getters.
Occasionally, the prefix "get" appears in a Cocoa method, like this
one:


- (void)getObjects:(id *)objects andKeys:(id *)keys


When a method is prefixed with get in Cocoa, what is being expressed?


Thanks,
-s
___

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 [EMAIL PROTECTED]


How would you tell WebKit to keep all JavaScript popup windows on top/in front?

2008-07-28 Thread Sumner Trammell
Hi, I've used WebKit to write a small Single-Site Browser that takes
you straight to a special section of the company intranet. It works
great, but there is one particular link on the page that creates a
popup window using JavaScript.  I want this popup to always stay on
top. In other words, I don't want the main window to ever hide the
popup. I'm not sure how to do this.  How would you tell WebKit to keep
all popup windows on top/in front?

Thanks,
-s
___

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 [EMAIL PROTECTED]


Re: NSTimer and a problem with document-based apps

2008-07-28 Thread Sumner Trammell
Thanks guys. Using class methods was a brilliant idea. Solidified my
understanding of when I might want to use them, and when I might want
to use @synchronized as well.


-s

On Sat, Jul 26, 2008 at 7:30 PM, Todd Heberlein <[EMAIL PROTECTED]> wrote:
>> - (id)init {
>> ...
>> timer = [NSTimer scheduledTimerWithTimeInterval:10.0
>> ...
>> }
>
> ...
>>
>> That new instance of course calls init, and suddenly I have two NSTimers
>> running when I only wanted one timer for the whole app.
>
> I think you want to make your timer a global variable and then initialize it
> within a call to a +load or +initialize method for one of your classes. See
> the following link:
>
> http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Executing-code-before-main.html
>
> Todd
>
>
___

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 [EMAIL PROTECTED]


Re: Getting process table info from within a Cocoa app

2008-07-28 Thread Sumner Trammell
Thanks guys. I thought I'd post my solution. The difference between my
solution and the examples on the net that I was able to find is that I
already know the pid -- I just want to see if that pid is still
running, if it's running as root, and if it has a certain name.

Although the Cocoa content is minimal, this might be useful for
someone who might otherwise end up using NSTask and NSPipe to look for
running processes, creating lots of overhead.

Studying sysctl(3), /usr/include/sys/proc.h, and
/usr/include/sys/sysctl.h, here's what I came up with:

#import 
#import 
#import 
#import 
#define MAXCHARS 8
#define MIBSIZE 4
#define PIDFILE "/var/run/some_VPN_pppd.pid"

- (BOOL)isVPNRunning {

char line[MAXCHARS];
FILE *fp;

if ((fp = fopen (PIDFILE, "r")) == NULL) {
//pid file does not exist; vpn is not running
//NSLog (@"vpn is not running 1");
return NO;
} else {
if ((fgets (line, MAXCHARS, fp)) == NULL) {
//pid file exists but is weirdly empty or otherwise 
unreadable;
presume vpn is not running
fclose (fp);
//NSLog (@"vpn is not running 2");
return NO;
} else {
fclose (fp);
int pid = atoi (line);

//got the pid from the pid file
//get the process table info for that pid

int mib[MIBSIZE];   
struct kinfo_proc kp;
size_t len = sizeof(kp);

mib[0]=CTL_KERN;
mib[1]=KERN_PROC;
mib[2]=KERN_PROC_PID;
mib[3]=pid;

if (sysctl(mib, MIBSIZE, &kp, &len, NULL, 0) == -1) {
//there was a problem getting the process info; 
presume vpn is not running
//NSLog (@"vpn is not running 3");
return NO;
} else {
if (len > 0) {
//there is a running process with that 
pid
//is the process owned by root?
if (kp.kp_eproc.e_pcred.p_svuid == 0) {

//process is owned by root
//is that process named pppd?
if (!strcmp("pppd", 
kp.kp_proc.p_comm)) {
//VPN IS RUNNING
//NSLog (@"vpn is 
running with pid = %d, uid = %d, process name
= %s", pid, kp.kp_eproc.e_pcred.p_svuid, kp.kp_proc.p_comm);
return YES; 

} else {
//process is owned by 
root but is not pppd; vpn is not running
//NSLog (@"vpn is not 
running 4");
return NO;
}
} else {
//process is not owned by root; 
vpn is not running
//NSLog (@"vpn is not running 
5");
return NO;
}

} else {
//there was some weird error in sysctl; 
presume vpn is not running
//NSLog (@"vpn is not running 6");
return NO;
}
}
}
}
}       


On Sat, Jul 26, 2008 at 8:44 PM, Ken Thomases <[EMAIL PROTECTED]> wrote:
>
> On Jul 26, 2008, at 12:58 AM, Sumner Trammell wrote:
>
>> Hi. A daemon process is running independently of my Cocoa app.  Given a pid
>> file of the daemon process in a known location, say /var/run/somedaemon.pid,
>> I would like my Cocoa app to read that file and check the process table to
>> see if the daemon is actually running. If the daemon

NSTimer and a problem with document-based apps

2008-07-26 Thread Sumner Trammell
Hi. I'm writing a Cocoa document-based app (using the Xcode template) that
uses a WebView and needs an NSTimer to trigger one of the methods every 10
seconds in the MyDocument class.  In my init method, I set up the timer:

@interface MyDocument : NSDocument
{
IBOutlet WebView *webView;
NSTimer *timer;
}



@implementation MyDocument

- (id)init {

self = [super init];
if (self) {
timer = [NSTimer scheduledTimerWithTimeInterval:10.0
 target:self
   selector:@selector(checkVPN:)
   userInfo:nil
repeats:YES];
[timer retain];
}

return self
}
.
.
.




The timer runs fine and the web view gets initialized and displays webpages
properly. Everything is fine until you click a link in the web view, and
that particular link happens to open up a new window, which is now a new
instance of MyDocument.

That new instance of course calls init, and suddenly I have two NSTimers
running when I only wanted one timer for the whole app.

I'm not sure how to do what I want the right way.  I think I need to
initialize the timer "further up," to put it lamely. Where should I do this?
 In main()?  Do I need to subclass something that NSDocument is a descendant
of?  Can anyone point me ot examples of how to do this the right way?

I've read the NSRunLoop and NSTimer docs, but I'm still not sure how to fix
this.

Thanks.

-s
___

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 [EMAIL PROTECTED]


Getting process table info from within a Cocoa app

2008-07-25 Thread Sumner Trammell
Hi. A daemon process is running independently of my Cocoa app.  Given a pid
file of the daemon process in a known location, say /var/run/somedaemon.pid,
I would like my Cocoa app to read that file and check the process table to
see if the daemon is actually running. If the daemon IS running, I want my
Cocoa app to change its Dock icon.
Is there a canonical Cocoa way of doing this? Using NSTask and NSPipe to run
/bin/ps seems like a kludge.

I couldn't find anything useful in the NSProcessInfo class docs or the
"Interacting with the Operating System" guide.


Thanks,
-s
___

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 [EMAIL PROTECTED]