Modal Window for NSTextField

2012-01-02 Thread Dany Golubitsky
Hello everyone!

I would like to ask your help with a specific problem I have.

I need to implement the following thing:
There is a control displaying numeric value. When you Double-Click on a control 
small white window appears where you can enter the value, and when you press 
enter the value will be updated.
You can see this screenshot (Ignore the fact it is from Windows 7):

http://i31.fastpic.ru/big/2012/0102/5e/3d39b295e3dc2642ff1d0f240da0c95e.png



Here is the code. I do it not within the main view but from the side function. 
The superView is the main view.

NSRect textRect = NSMakeRect(in_location.m_x, in_location.m_y, in_size.m_x, 
in_size.m_y);
NSTextField* textField = [[NSTextField alloc] initWithFrame:textRect];

// Configure the text field
[textField setEditable:YES];
[textField setSelectable:YES];
[textField setWantsLayer:YES];
[textField setImportsGraphics:NO];
[textField setBordered:NO];
[textField setBezeled:NO];
[textField setBackgroundColor:[NSColor whiteColor]];
[textField setDrawsBackground:YES];
[textField setTextColor:[NSColor blackColor]];
[textField setAllowsEditingTextAttributes:NO];
[textField setAutoresizingMask:(NSUInteger)(NSViewWidthSizable + 
NSViewHeightSizable)];

// Embed the text field in our plug-in view.
[superView addSubview:textField];
[superView setAutoresizesSubviews:YES];

// Make the text field "in focus", and start an editing session on it
[textField becomeFirstResponder];

Now I tried 2 approaches:

1)

*out_dismissedKey = [NSApp runModalForWindow:[textField window]];
[textField removeFromSuperview];
[textField release];

This one works. The text window gets all the events and I can get what I want. 
However, the windows order get screwed, meaning if there are couple of windows 
open in the same application the superView gets beyond other windows and I can 
not get it on front again.

So I tried the second approach - sheets:

2)

[textField beginSheetModalForWindow:[superView window] modalDelegate:superView 
didEndSelector:0 contextInfo:0];
[textField removeFromSuperview];
[textField release];

Now the problem here is that I am getting stuck in this function. The window is 
opened but neither Enter nor Escape do not close it. So the caller function can 
not continue, meaning I can not reach
[textField removeFromSuperview].

Can someone help me either with first or the second issue?
I understand that the explanation may be insufficient, I am ready to give more 
and the screenshots if anyone wishes.

Thanks!

[cid:image001.jpg@01CCC950.1B952E70]

Dany Golubitsky
Software Engineer

Waves Audio Ltd
Tel:  +972 3 608 4157
Fax: +972 3 608 4056

www.waves.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: Modal Window for NSTextField

2012-01-02 Thread Michael Babin
On Jan 2, 2012, at 6:02 AM, Dany Golubitsky wrote:

> I need to implement the following thing:
> There is a control displaying numeric value. When you Double-Click on a 
> control small white window appears where you can enter the value, and when 
> you press enter the value will be updated.
> You can see this screenshot (Ignore the fact it is from Windows 7):
> 
> http://i31.fastpic.ru/big/2012/0102/5e/3d39b295e3dc2642ff1d0f240da0c95e.png

What you are trying to implement sounds very similar to the standard field 
editor used in Cocoa 
(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextEditing/Tasks/FieldEditor.html).

If you aren't familiar with it, I'd advise taking some time to investigate it 
and see if you can adapt it to your needs. Even if not, the description of how 
it works (integration with responder chain, delegate methods) should prove 
useful. I would recommend it over the approach of trying to force application 
or window modal operation.

> Here is the code. I do it not within the main view but from the side 
> function. The superView is the main view.
> 
> NSRect textRect = NSMakeRect(in_location.m_x, in_location.m_y, 
> in_size.m_x, in_size.m_y);
> NSTextField* textField = [[NSTextField alloc] initWithFrame:textRect];
> 
> // Configure the text field
> [textField setEditable:YES];
> [textField setSelectable:YES];
> [textField setWantsLayer:YES];
> [textField setImportsGraphics:NO];
> [textField setBordered:NO];
> [textField setBezeled:NO];
> [textField setBackgroundColor:[NSColor whiteColor]];
> [textField setDrawsBackground:YES];
> [textField setTextColor:[NSColor blackColor]];
> [textField setAllowsEditingTextAttributes:NO];
> [textField setAutoresizingMask:(NSUInteger)(NSViewWidthSizable + 
> NSViewHeightSizable)];
> 
> // Embed the text field in our plug-in view.
> [superView addSubview:textField];
> [superView setAutoresizesSubviews:YES];
> 
> // Make the text field "in focus", and start an editing session on it
> [textField becomeFirstResponder];
> 
> Now I tried 2 approaches:
> 
> 1)
> 
> *out_dismissedKey = [NSApp runModalForWindow:[textField window]];
> [textField removeFromSuperview];
> [textField release];
> 
> This one works. The text window gets all the events and I can get what I 
> want. However, the windows order get screwed, meaning if there are couple of 
> windows open in the same application the superView gets beyond other windows 
> and I can not get it on front again.

Given the code, it looks like you're trying to force the window with the text 
field into an application modal "mode". Don't do this.

> So I tried the second approach - sheets:
> 
> 2)
> 
> [textField beginSheetModalForWindow:[superView window] 
> modalDelegate:superView didEndSelector:0 contextInfo:0];
> [textField removeFromSuperview];
> [textField release];
> 
> Now the problem here is that I am getting stuck in this function. The window 
> is opened but neither Enter nor Escape do not close it. So the caller 
> function can not continue, meaning I can not reach
> [textField removeFromSuperview].

So textField is an NSSavePanel or NSAlert? Those seem to be the only objects 
(other than more obscure objects like ABIdentityPicker) with 
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: methods.

I'll assume you meant  - [NSApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]. It 
requires an endSheet call (delegate method? notification?) to exit. In any 
case, I would not recommend this approach either.

___

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: Static variables reset inside CFPlugin code

2012-01-02 Thread Grandinetti Philip
Sorry Jens,

I read too quickly.   The app is for the physical and engineering sciences, and 
will perform a least squares fit of experimental data to different physical 
models.The models for the experimental data will be in the plugins, and the 
user will likely only need to the load a few of the plugin models.   In the 
host app (actually in one of it's static libraries dedicated to handling SI 
Units) is a static variable pointing to a singleton library (CFMutableSet) with 
a growing set of SI units available in the main app (and plugins).   The units 
are flyweights, so I don't want multiple copies floating around the program.

So, I can't really define the static variable pointing to my library in the 
plugin.It needs to be defined in the library that handles all the SI units.

Is it still possible to tell the linker to export the static variable pointing 
to my SI Units library in such a situation? 

Thanks again,

Philip

On Jan 1, 2012, at 9:49 PM, Jens Alfke wrote:

> 
> On Jan 1, 2012, at 2:21 PM, Grandinetti Philip wrote:
> 
>> Your suggestions make sense, although...
>> option (a) doesn't work for me, since the static variables are being used 
>> before the plugin is loaded.   
> 
> They're not options, they're steps. You need to do all of them.
> 
> If you can't put the variable in the plugin, I _think_ you can put it in the 
> app, then export it from the app and link the plugin against the app. Apps 
> don't normally export symbols, but I think you can set this up.
> 
> Maybe you could explain what the plugin does and why it and the app need to 
> share a variable?
> 
> —Jens

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UIView is sized out of the blue

2012-01-02 Thread Alexander Reichstadt
Hi,

when returning from my detail view the list view is sized out of the blue.

in viewDidAppear I do this:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([theSearchbar.text length]){
[theSearchbar becomeFirstResponder];
[self switchSearchbarInvisible:NO];
} else {
[theSearchbar resignFirstResponder];
[self switchSearchbarInvisible:YES];
}

}



In switchSearchbarInvisible: I do this:

- (void)switchSearchbarInvisible:(BOOL)isHidden
{
theSearchbar.hidden=isHidden;
CGRect tvbounds = [uiTableView bounds];

CGFloat ypos;
CGFloat yheight;
if (isHidden){
ypos = 0;
alphabetChoiceView.rowHeight=15.5;
} else {
ypos = 42;
alphabetChoiceView.rowHeight=14;
}

yheight = 406-ypos;
[uiTableView setFrame:CGRectMake(29, 
  ypos, 
  292, 
  yheight)];

tvbounds = [alphabetChoiceView bounds];
[alphabetChoiceView setFrame:CGRectMake(0, 
 ypos+2, 
 28, 
 yheight)];



if (!isHidden){
for (UIView *possibleButton in theSearchbar.subviews)
{
if ([possibleButton isKindOfClass:[UIButton class]])
{
UIButton *cancelButton = (UIButton*)possibleButton;
cancelButton.enabled = YES;
break;
}
}
}

[alphabetChoiceView setNeedsLayout];
[uiTableView setNeedsLayout];
[alphabetChoiceView setNeedsDisplay];
[alphabetChoiceView reloadData];
[self.view setNeedsLayout];
[self.view setNeedsDisplay];
 

}


Upon launching the app it works fine, so the via is correctly layouted. But 
once visiting the detail page it gets screwed up and the list view is pushed 
below the bottom toolbar. yheight is completely ignored.

As you can see I tried to refresh every contained view with everything I 
thought would make a change, but it seems that this all gets ignored. My 
question is how to make CocoaTouch stop ignoring my changes? I tried to have 
this called in viewDidLoad, viewWillLoad, viewWillAppear, viewDidAppear to no 
avail?

___

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: Modal Window for NSTextField

2012-01-02 Thread Dany Golubitsky
Thank you!

As for field editor - can it appear and disappear during runtime? Indeed, I do 
not familiar with this approach.

About beginSheetModalForWindow - indeed, I tried to do the following either:
[textField beginSheet:[textField window] ModalForWindow:[superView window] 
modalDelegate:superView didEndSelector:0 contextInfo:0];

and yes, I implemented endSheet. I tried to call endSheet from mouseDown event. 
I saw this function being called, however still, the white window was not 
closed and I was stuck in beginSheet (The code after it was unreachable).

Can you suggest why?




-Original Message-
From: Michael Babin [mailto:mba...@orderndev.com] 
Sent: Monday, January 02, 2012 16:10
To: Dany Golubitsky
Cc: cocoa-dev@lists.apple.com
Subject: Re: Modal Window for NSTextField

On Jan 2, 2012, at 6:02 AM, Dany Golubitsky wrote:

> I need to implement the following thing:
> There is a control displaying numeric value. When you Double-Click on a 
> control small white window appears where you can enter the value, and when 
> you press enter the value will be updated.
> You can see this screenshot (Ignore the fact it is from Windows 7):
> 
> http://i31.fastpic.ru/big/2012/0102/5e/3d39b295e3dc2642ff1d0f240da0c95
> e.png

What you are trying to implement sounds very similar to the standard field 
editor used in Cocoa 
(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextEditing/Tasks/FieldEditor.html).

If you aren't familiar with it, I'd advise taking some time to investigate it 
and see if you can adapt it to your needs. Even if not, the description of how 
it works (integration with responder chain, delegate methods) should prove 
useful. I would recommend it over the approach of trying to force application 
or window modal operation.

> Here is the code. I do it not within the main view but from the side 
> function. The superView is the main view.
> 
> NSRect textRect = NSMakeRect(in_location.m_x, in_location.m_y, 
> in_size.m_x, in_size.m_y);
> NSTextField* textField = [[NSTextField alloc] initWithFrame:textRect];
> 
> // Configure the text field
> [textField setEditable:YES];
> [textField setSelectable:YES];
> [textField setWantsLayer:YES];
> [textField setImportsGraphics:NO];
> [textField setBordered:NO];
> [textField setBezeled:NO];
> [textField setBackgroundColor:[NSColor whiteColor]]; [textField 
> setDrawsBackground:YES]; [textField setTextColor:[NSColor 
> blackColor]]; [textField setAllowsEditingTextAttributes:NO];
> [textField setAutoresizingMask:(NSUInteger)(NSViewWidthSizable + 
> NSViewHeightSizable)];
> 
> // Embed the text field in our plug-in view.
> [superView addSubview:textField];
> [superView setAutoresizesSubviews:YES];
> 
> // Make the text field "in focus", and start an editing session on it 
> [textField becomeFirstResponder];
> 
> Now I tried 2 approaches:
> 
> 1)
> 
> *out_dismissedKey = [NSApp runModalForWindow:[textField window]]; 
> [textField removeFromSuperview]; [textField release];
> 
> This one works. The text window gets all the events and I can get what I 
> want. However, the windows order get screwed, meaning if there are couple of 
> windows open in the same application the superView gets beyond other windows 
> and I can not get it on front again.

Given the code, it looks like you're trying to force the window with the text 
field into an application modal "mode". Don't do this.

> So I tried the second approach - sheets:
> 
> 2)
> 
> [textField beginSheetModalForWindow:[superView window] 
> modalDelegate:superView didEndSelector:0 contextInfo:0]; [textField 
> removeFromSuperview]; [textField release];
> 
> Now the problem here is that I am getting stuck in this function. The 
> window is opened but neither Enter nor Escape do not close it. So the caller 
> function can not continue, meaning I can not reach [textField 
> removeFromSuperview].

So textField is an NSSavePanel or NSAlert? Those seem to be the only objects 
(other than more obscure objects like ABIdentityPicker) with 
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: methods.

I'll assume you meant  - [NSApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]. It 
requires an endSheet call (delegate method? notification?) to exit. In any 
case, I would not recommend this approach either.

___

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: UIView is sized out of the blue

2012-01-02 Thread Alexander Reichstadt
I found the issue. The navigation bar was first shown and then removed, thus I 
ended calculating a wrong size.

Thanks

On 02.01.2012, at 16:17, Alexander Reichstadt wrote:

> Hi,
> 
> when returning from my detail view the list view is sized out of the blue.
> 
> in viewDidAppear I do this:
> - (void)viewDidAppear:(BOOL)animated
> {
>[super viewDidAppear:animated];
>if ([theSearchbar.text length]){
>[theSearchbar becomeFirstResponder];
>[self switchSearchbarInvisible:NO];
>} else {
>[theSearchbar resignFirstResponder];
>[self switchSearchbarInvisible:YES];
>}
> 
> }
> 
> 
> 
> In switchSearchbarInvisible: I do this:
> 
> - (void)switchSearchbarInvisible:(BOOL)isHidden
> {
>theSearchbar.hidden=isHidden;
>CGRect tvbounds = [uiTableView bounds];
> 
>CGFloat ypos;
>CGFloat yheight;
>if (isHidden){
>ypos = 0;
>alphabetChoiceView.rowHeight=15.5;
>} else {
>ypos = 42;
>alphabetChoiceView.rowHeight=14;
>}
> 
>yheight = 406-ypos;
>[uiTableView setFrame:CGRectMake(29, 
>  ypos, 
>  292, 
>  yheight)];
> 
>tvbounds = [alphabetChoiceView bounds];
>[alphabetChoiceView setFrame:CGRectMake(0, 
> ypos+2, 
> 28, 
> yheight)];
> 
> 
> 
>if (!isHidden){
>for (UIView *possibleButton in theSearchbar.subviews)
>{
>if ([possibleButton isKindOfClass:[UIButton class]])
>{
>UIButton *cancelButton = (UIButton*)possibleButton;
>cancelButton.enabled = YES;
>break;
>}
>}
>}
> 
>[alphabetChoiceView setNeedsLayout];
>[uiTableView setNeedsLayout];
>[alphabetChoiceView setNeedsDisplay];
>[alphabetChoiceView reloadData];
>[self.view setNeedsLayout];
>[self.view setNeedsDisplay];
> 
> 
> }
> 
> 
> Upon launching the app it works fine, so the via is correctly layouted. But 
> once visiting the detail page it gets screwed up and the list view is pushed 
> below the bottom toolbar. yheight is completely ignored.
> 
> As you can see I tried to refresh every contained view with everything I 
> thought would make a change, but it seems that this all gets ignored. My 
> question is how to make CocoaTouch stop ignoring my changes? I tried to have 
> this called in viewDidLoad, viewWillLoad, viewWillAppear, viewDidAppear to no 
> avail?
> 
> ___
> 
> 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/lxr%40mac.com
> 
> This email sent to l...@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: Static variables reset inside CFPlugin code

2012-01-02 Thread Steve Sisak

At 9:47 AM -0500 1/2/12, Grandinetti Philip wrote:
So, I can't really define the static variable pointing to my library 
in the plugin.It needs to be defined in the library that handles 
all the SI units.


Hi Philip,

This is dusting off brain cells that I haven't used in awhile but, 
assuming all the plugins run only in your application, you could put 
all of the code/data shared by the plugins into a framework that 
resides in your application bundle.


Your application and your plugins then link against this framework.

You could use either CFPlugin or NSBundle as Chris suggests.

The tough part here is all the Xcode magic to get the targets set up 
correctly -- I'm currently working out something similar, and will 
post results.


If someone has a recipe for setting this up in Xcode 4 and would be 
willing to post it, I'd be interested as well.


HTH,

-Steve
___

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: Modal Window for NSTextField

2012-01-02 Thread Michael Babin
On Jan 2, 2012, at 9:22 AM, Dany Golubitsky wrote:

> Thank you!
> 
> As for field editor - can it appear and disappear during runtime? Indeed, I 
> do not familiar with this approach.

"The field editor is a single NSTextView object that is shared among all the 
controls in a single window, including buttons, table views, and text fields. 
This text view object provides text entry and editing services for the 
currently active control. When the user clicks in a text field, for example, 
the field editor begins handling keystroke events and text display for that 
field."

So, yes.

> About beginSheetModalForWindow - indeed, I tried to do the following either:
> [textField beginSheet:[textField window] ModalForWindow:[superView window] 
> modalDelegate:superView didEndSelector:0 contextInfo:0];

Again assuming that you mean  - [NSApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:], you would 
not send that message to textField (which is not an NSApplication object, 
unless your approach/naming has changed much more radically than described).

Given that textField is a subview of superView, you're attempting to use a 
window as a sheet for itself. I doubt that approach would yield useful results.

> and yes, I implemented endSheet. I tried to call endSheet from mouseDown 
> event. I saw this function being called, however still, the white window was 
> not closed and I was stuck in beginSheet (The code after it was unreachable).
> 
> Can you suggest why?

- [NSApplication endSheet:] and -[NSApplication endSheet: returnCode:] do work 
to end a modal session using a sheet, in my experience, provided you supply the 
appropriate arguments. Your problem could also be due to trying to use a window 
as a sheet for itself, as mentioned previously.

___

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: Static variables reset inside CFPlugin code

2012-01-02 Thread Grandinetti Philip
Hi Steve,

You raise a fundamental issue that I admit I don't completely understand.   
What are the differences between linking against a static library versus a 
framework.   If I turned all my static libraries into a framework would the 
plugin see the static variables in the framework without having to do all the 
Xcode linking magic?

Thanks,

Philip

On Jan 2, 2012, at 10:26 AM, Steve Sisak wrote:

> At 9:47 AM -0500 1/2/12, Grandinetti Philip wrote:
>> So, I can't really define the static variable pointing to my library in the 
>> plugin.It needs to be defined in the library that handles all the SI 
>> units.
> 
> Hi Philip,
> 
> This is dusting off brain cells that I haven't used in awhile but, assuming 
> all the plugins run only in your application, you could put all of the 
> code/data shared by the plugins into a framework that resides in your 
> application bundle.
> 
> Your application and your plugins then link against this framework.
> 
> You could use either CFPlugin or NSBundle as Chris suggests.
> 
> The tough part here is all the Xcode magic to get the targets set up 
> correctly -- I'm currently working out something similar, and will post 
> results.
> 
> If someone has a recipe for setting this up in Xcode 4 and would be willing 
> to post it, I'd be interested as well.
> 
> HTH,
> 
> -Steve

___

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


NSTextView, spell checking and temporary attributes

2012-01-02 Thread Martin Hewitson
Dear list,

I have an NSTextView subclass which I've set up to highlight matching words in 
view. So if the user highlights a word, all matching words are highlighted. I'm 
doing the highlighting using a temporary attribute on the layout manager: 
NSBackgroundColorAttributeName.

In order for this to work, I first remove this attributed in the visible range 
of text:

[[self layoutManager] removeTemporaryAttribute:NSBackgroundColorAttributeName 
forCharacterRange:visibleRange];

This has the unfortunate side-effect of removing the red squiggly lines which 
indicate misspelled words.

So, I was trying to think of ways out of this. I could cycle through all 
temporary attributes in view and only remove those where 
NSBackgroundColorAttributeName is the color of my highlighting. This seems a 
bit heavy.

I was wondering if I could do the removal and then get the text view to 
re-highlight the misspelled words, but I couldn't find a way to make it do 
that. 

Any ideas?

Best wishes

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: Static variables reset inside CFPlugin code

2012-01-02 Thread Jens Alfke

On Jan 2, 2012, at 7:52 AM, Grandinetti Philip wrote:

> You raise a fundamental issue that I admit I don't completely understand.   
> What are the differences between linking against a static library versus a 
> framework.   If I turned all my static libraries into a framework would the 
> plugin see the static variables in the framework without having to do all the 
> Xcode linking magic?

The difference is copying vs. referencing. A static library gets copied into 
the target at link time, whereas if you link with a dynamic library or 
framework, the linker just notes down what symbols are referenced, and at load 
time those get resolved to those symbols in the library.

For your purposes, the difference is that in a static library, everything that 
links with it has its own private copy of the library's global variables. In a 
dylib/framework, everything that links with it shares its global variables. The 
latter is what you want.

—Jens

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Modal Window for NSTextField

2012-01-02 Thread Seth Willits
On Jan 2, 2012, at 4:02 AM, Dany Golubitsky wrote:

> // Make the text field "in focus", and start an editing session on it
> [textField becomeFirstResponder];

-becomeFirstResponder is a notification method for when the responder becomes 
first responder; it doesn't *make* it first responder. For that you want 
[window makeFirstResponder:].



> Now I tried 2 approaches:

Both are wacky as Michael explained.


You do not need the window to be modal at all. The solution is really simple. 
Just start editing the text field, and when the editing is done 
(controlTextDidEndEditing: notification), you just remove the text field. 


--
Seth Willits
___

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


CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Michael Crawford
I'm trying to hide the cursor when in full-screen mode on Lion but the 
CGDisplayHideCursor call immediately takes the display out of full-screen mode. 
 It doesn't matter which call comes first, I get the same result every time.

Here's the code:

- (void)applicationDidFinishLaunching:(NSNotification*)notification
{
if ( NO == [[NSUserDefaults standardUserDefaults] developerMode] )
{
// disable idle and display sleep
[self disableDisplaySleep];
[self disableIdleSleep];

// enter full-screen mode
[self.window toggleFullScreen:self];

// hide cursor (mouse pointer)
CGDisplayHideCursor(kCGDirectMainDisplay);
}

// create views and pass in model for binding
menuViewController = [[JTVMenuViewController alloc] 
initWithPlaylist:self.moviePlaylist];
[menuViewController loadView];

movieViewController = [[JTVMovieViewController alloc] 
initWithPlaylist:self.moviePlaylist];
[movieViewController loadView];
movieViewController.delegate = self;

// start with the menu as the main view
[self.window.contentView setWantsLayer:YES];
[self.window.contentView addSubview:menuViewController.view];
}

-Michael
___

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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Seth Willits
On Jan 2, 2012, at 10:30 AM, Michael Crawford wrote:

> I'm trying to hide the cursor when in full-screen mode on Lion but the 
> CGDisplayHideCursor call immediately takes the display out of full-screen 
> mode.  It doesn't matter which call comes first, I get the same result every 
> time.

Works fine here.



--
Seth Willits
___

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: NSTextView, spell checking and temporary attributes

2012-01-02 Thread Seth Willits
On Jan 2, 2012, at 10:20 AM, Martin Hewitson wrote:

> [[self layoutManager] removeTemporaryAttribute:NSBackgroundColorAttributeName 
> forCharacterRange:visibleRange];
> 
> This has the unfortunate side-effect of removing the red squiggly lines which 
> indicate misspelled words.


Hmm. Works fine here.


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[textView setString:@"Hello this is a reallly good day to be alive."];
[[textView layoutManager] 
addTemporaryAttribute:NSBackgroundColorAttributeName value:[NSColor 
yellowColor] forCharacterRange:NSMakeRange(6, 4)];
[[textView layoutManager] 
addTemporaryAttribute:NSBackgroundColorAttributeName value:[NSColor 
yellowColor] forCharacterRange:NSMakeRange(16, 7)];
[textView checkTextInDocument:nil];
}


- (IBAction)action:(id)sender;
{
[[textView layoutManager] 
removeTemporaryAttribute:NSBackgroundColorAttributeName 
forCharacterRange:NSMakeRange(0, textView.string.length)];
}



--
Seth Willits___

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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Michael Crawford
Seth, don't run from inside Xcode.  Start the app from the finder.  I find that 
in that instance, it goes to full screen and then immediately exits full screen.

Here is a trace:

1/2/12 1:51:21.428 PM JTVideoPlayer: -[JTVAppDelegate 
window:willUseFullScreenPresentationOptions:]
1/2/12 1:51:21.429 PM JTVideoPlayer: -[JTVAppDelegate 
windowWillEnterFullScreen:]
1/2/12 1:51:21.441 PM JTVideoPlayer: -[JTVAppDelegate 
window:willUseFullScreenContentSize:]
1/2/12 1:51:21.448 PM JTVideoPlayer: -[JTVAppDelegate windowDidEnterFullScreen:]
1/2/12 1:51:21.532 PM JTVideoPlayer: -[JTVAppDelegate windowWillExitFullScreen:]
1/2/12 1:51:22.886 PM JTVideoPlayer: -[JTVAppDelegate windowDidExitFullScreen:]


-Michael

On Jan 2, 2012, at 1:52 PM, Seth Willits wrote:

> On Jan 2, 2012, at 10:30 AM, Michael Crawford wrote:
> 
>> I'm trying to hide the cursor when in full-screen mode on Lion but the 
>> CGDisplayHideCursor call immediately takes the display out of full-screen 
>> mode.  It doesn't matter which call comes first, I get the same result every 
>> time.
> 
> Works fine here.
> 
> 
> 
> --
> Seth Willits
> ___
> 
> 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/michaelacrawford%40me.com
> 
> This email sent to michaelacrawf...@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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Seth Willits

Still works fine. Can you repeat it in a sample project that I can test? 



On Jan 2, 2012, at 11:27 AM, Michael Crawford wrote:

> Seth, don't run from inside Xcode.  Start the app from the finder.  I find 
> that in that instance, it goes to full screen and then immediately exits full 
> screen.
> 
> 
> -Michael
> 
> On Jan 2, 2012, at 1:52 PM, Seth Willits wrote:
> 
>> On Jan 2, 2012, at 10:30 AM, Michael Crawford wrote:
>> 
>>> I'm trying to hide the cursor when in full-screen mode on Lion but the 
>>> CGDisplayHideCursor call immediately takes the display out of full-screen 
>>> mode.  It doesn't matter which call comes first, I get the same result 
>>> every time.
>> 
>> Works fine here.
>> 

___

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: Setting ApplePressAndHoldEnabled key for specific application.

2012-01-02 Thread Jens Alfke

On Jan 1, 2012, at 8:44 PM, Vaibhao Mahore wrote:

> 2.   I have tried with setting defaults for my application with 
> ApplePressAndHoldEnabled being NO. I can even read defaults for my 
> application using
> defaults read < my application bundle-identifier >
> Still I am unable to see "Press and Hold  for Certain keys" feature disable 
> for my application.

Did you try forcing a boolean value for the default? I’ve had problems before 
where some system code only understands a boolean false, not the string “NO”.

defaults write my.bundle.id ApplePressAndHoldEnabled --bool NO

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Kyle Sluder
On Jan 2, 2012, at 11:27 AM, Michael Crawford  wrote:

> Seth, don't run from inside Xcode.  Start the app from the finder.  I find 
> that in that instance, it goes to full screen and then immediately exits full 
> screen.

Try launching with Shift held down to clear restorable window state.

--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: NSTextView, spell checking and temporary attributes

2012-01-02 Thread Douglas Davidson
Are you making other modifications to temporary attributes?  The spelling 
indicator does use various temporary attributes, though not background color, 
so (for example) clearing temporary attributes would interfere with it. 

Douglas Davidson

On Jan 2, 2012, at 10:20 AM, Martin Hewitson  wrote:

> Dear list,
> 
> I have an NSTextView subclass which I've set up to highlight matching words 
> in view. So if the user highlights a word, all matching words are 
> highlighted. I'm doing the highlighting using a temporary attribute on the 
> layout manager: NSBackgroundColorAttributeName.
> 
> In order for this to work, I first remove this attributed in the visible 
> range of text:
> 
> [[self layoutManager] removeTemporaryAttribute:NSBackgroundColorAttributeName 
> forCharacterRange:visibleRange];
> 
> This has the unfortunate side-effect of removing the red squiggly lines which 
> indicate misspelled words.
> 
> So, I was trying to think of ways out of this. I could cycle through all 
> temporary attributes in view and only remove those where 
> NSBackgroundColorAttributeName is the color of my highlighting. This seems a 
> bit heavy.
> 
> I was wondering if I could do the removal and then get the text view to 
> re-highlight the misspelled words, but I couldn't find a way to make it do 
> that. 
> 
> Any ideas?
> 
> Best wishes
> 
> 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/ddavidso%40apple.com
> 
> This email sent to ddavi...@apple.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: NSTextView, spell checking and temporary attributes

2012-01-02 Thread Martin Hewitson
Yes, it seems I was mistaken. I also made a test app and can't reproduce the 
problem. So it must be something else I'm doing with the textview that stops 
the continuous spell checking from working.

Oh well, more digging to do.

Thanks for confirming!

Martin


On 2, Jan, 2012, at 08:07 PM, Seth Willits wrote:

> On Jan 2, 2012, at 10:20 AM, Martin Hewitson wrote:
> 
>> [[self layoutManager] 
>> removeTemporaryAttribute:NSBackgroundColorAttributeName 
>> forCharacterRange:visibleRange];
>> 
>> This has the unfortunate side-effect of removing the red squiggly lines 
>> which indicate misspelled words.
> 
> 
> Hmm. Works fine here.
> 
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
>   [textView setString:@"Hello this is a reallly good day to be alive."];
>   [[textView layoutManager] 
> addTemporaryAttribute:NSBackgroundColorAttributeName value:[NSColor 
> yellowColor] forCharacterRange:NSMakeRange(6, 4)];
>   [[textView layoutManager] 
> addTemporaryAttribute:NSBackgroundColorAttributeName value:[NSColor 
> yellowColor] forCharacterRange:NSMakeRange(16, 7)];
>   [textView checkTextInDocument:nil];
> }
> 
> 
> - (IBAction)action:(id)sender;
> {
>   [[textView layoutManager] 
> removeTemporaryAttribute:NSBackgroundColorAttributeName 
> forCharacterRange:NSMakeRange(0, textView.string.length)];
> }
> 
> 
> 
> --
> Seth Willits___
> 
> 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/martin.hewitson%40aei.mpg.de
> 
> This email sent to martin.hewit...@aei.mpg.de


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Michael Crawford
Thank you, Kyle.  That works.

-Michael

On Jan 2, 2012, at 3:16 PM, Kyle Sluder wrote:

> On Jan 2, 2012, at 11:27 AM, Michael Crawford  wrote:
> 
>> Seth, don't run from inside Xcode.  Start the app from the finder.  I find 
>> that in that instance, it goes to full screen and then immediately exits 
>> full screen.
> 
> Try launching with Shift held down to clear restorable window state.
> 
> --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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Michael Crawford
Seth, I appreciate your offer to help out by testing some code.  Now that Kyle 
has identified what is going on, I'm looking into programmatically disabling or 
overriding the window restoration behavior for my app.

-Michael

On Jan 2, 2012, at 4:44 PM, Michael Crawford wrote:

> Thank you, Kyle.  That works.
> 
> -Michael
> 
> On Jan 2, 2012, at 3:16 PM, Kyle Sluder wrote:
> 
>> On Jan 2, 2012, at 11:27 AM, Michael Crawford  
>> wrote:
>> 
>>> Seth, don't run from inside Xcode.  Start the app from the finder.  I find 
>>> that in that instance, it goes to full screen and then immediately exits 
>>> full screen.
>> 
>> Try launching with Shift held down to clear restorable window state.
>> 
>> --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/michaelacrawford%40me.com
> 
> This email sent to michaelacrawf...@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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-02 Thread Michael Crawford
For the benefit of anyone else who is watching and also has limited experience 
with some of the new Lion features, a call to [NSWindow setRestorable:] or 
flipping a switch in the interface builder UI for the NSWindow instance, 
handily solves the problem.

-Michael

On Jan 2, 2012, at 4:56 PM, Michael Crawford wrote:

> Seth, I appreciate your offer to help out by testing some code.  Now that 
> Kyle has identified what is going on, I'm looking into programmatically 
> disabling or overriding the window restoration behavior for my app.
> 
> -Michael
> 
> On Jan 2, 2012, at 4:44 PM, Michael Crawford wrote:
> 
>> Thank you, Kyle.  That works.
>> 
>> -Michael
>> 
>> On Jan 2, 2012, at 3:16 PM, Kyle Sluder wrote:
>> 
>>> On Jan 2, 2012, at 11:27 AM, Michael Crawford  
>>> wrote:
>>> 
 Seth, don't run from inside Xcode.  Start the app from the finder.  I find 
 that in that instance, it goes to full screen and then immediately exits 
 full screen.
>>> 
>>> Try launching with Shift held down to clear restorable window state.
>>> 
>>> --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/michaelacrawford%40me.com
>> 
>> This email sent to michaelacrawf...@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/michaelacrawford%40me.com
> 
> This email sent to michaelacrawf...@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


need to use NSManagedContext performBlock for contexts with NSMainQueueConcurrencyType?

2012-01-02 Thread davelist
If I create a child context of type NSMainQueueConcurrencyType such as:

context = [[NSManagedObjectContext alloc] 
initWithConcurrencyType:NSMainQueueConcurrencyType];
[context setParentContext:mainContext];

do I need to call [context performBlock:^{ // some code }];

or can I just use the context normally if I know the code is being executed on 
the main thread/queue?

Similarly, do I need to use performBlock on the UIManagedDocument's 
managedObjectContext property when I know the code is being executed on the 
main thread?

I think the answer to both questions is "no, you do not need to use 
performBlock", but I'd like to be certain.

Thanks,
Dave

___

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: Static variables reset inside CFPlugin code

2012-01-02 Thread Grandinetti Philip
Hi Jens,

Thanks for your patience.   I'm getting a better understanding.   Also, it 
helped a bit reading through ...

http://developer.apple.com/library/mac/#documentation/developertools/conceptual/MachOTopics
and
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/DynamicLibraries

However, I'm still not sure what is the right way to do this.   I have made the 
pointer global (no long declared as "static"),...

CFMutableSetRef unitsLibrary = NULL;

in my "Units" static library.   The main app begins using the "Units" library 
at startup and starts filling this set.   Then, eventually the plugin gets 
loaded. In the plugin factory function I added ...

CFBundleRef bundle = CFBundleGetMainBundle();
CFMutableSetRef *pointer =  CFBundleGetDataPointerForName 
(bundle,CFSTR("unitsLibrary"));
PSUnitSetLibrary(*pointer);

and this works!   The plugin now "knows" about all the previous units that were 
defined in the main app.

But I'm troubled by this solution.   If I set debugger break points in the 
"Units" library the debugger no longer stops at those breakpoints when called 
by the plugin, but it does stop at those breakpoints when called by the main 
app.   Makes me think I have two copies of code for my static units library 
running after the plugin is loaded.   Does that make sense?

Philip




On Jan 2, 2012, at 1:22 PM, Jens Alfke wrote:

> 
> On Jan 2, 2012, at 7:52 AM, Grandinetti Philip wrote:
> 
>> You raise a fundamental issue that I admit I don't completely understand.   
>> What are the differences between linking against a static library versus a 
>> framework.   If I turned all my static libraries into a framework would the 
>> plugin see the static variables in the framework without having to do all 
>> the Xcode linking magic?
> 
> The difference is copying vs. referencing. A static library gets copied into 
> the target at link time, whereas if you link with a dynamic library or 
> framework, the linker just notes down what symbols are referenced, and at 
> load time those get resolved to those symbols in the library.
> 
> For your purposes, the difference is that in a static library, everything 
> that links with it has its own private copy of the library's global 
> variables. In a dylib/framework, everything that links with it shares its 
> global variables. The latter is what you want.
> 
> —Jens
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextField subclass not working properly

2012-01-02 Thread Devarshi Kulshreshtha
Hi all,


I am using below code to subclass NSTextField-


- (void)drawRect:(NSRect)dirtyRect

{

// black outline

NSRect blackOutlineFrame = NSMakeRect(0.0, 0.0, [self
bounds].size.width, [self bounds].size.height-1.0);


NSGradient *gradient = nil;

if ([NSApp isActive]) {

gradient = [[NSGradient alloc] initWithStartingColor:[NSColor
colorWithCalibratedWhite:0.24 alpha:1.0] endingColor:[NSColor
colorWithCalibratedWhite:0.374 alpha:1.0]];

}

else {

gradient = [[NSGradient alloc] initWithStartingColor:[NSColor
colorWithCalibratedWhite:0.55 alpha:1.0] endingColor:[NSColor
colorWithCalibratedWhite:0.558 alpha:1.0]];

}

[gradient drawInBezierPath:[NSBezierPath
bezierPathWithRoundedRect:blackOutlineFrame xRadius:7.6 yRadius:7.6]
angle:90];




// top inner shadow

NSRect shadowFrame = NSMakeRect(1, 1, [self bounds].size.width-2.0,
10.0);

[[NSColor colorWithCalibratedWhite:0.88 alpha:1.0] set];

[[NSBezierPath bezierPathWithRoundedRect:shadowFrame xRadius:6.9
yRadius:6.9] fill];


// draw the keyboard focus ring if we're the first responder and the
application is active

if (([[self window] firstResponder] == [self currentEditor]) && [NSApp
isActive])

{

[NSGraphicsContext saveGraphicsState];

NSSetFocusRingStyle(NSFocusRingOnly);

[[NSBezierPath bezierPathWithRoundedRect:blackOutlineFrame
xRadius:8.6 yRadius:8.6] fill];

[NSGraphicsContext restoreGraphicsState];

}


// main white area


NSRect whiteFrame = NSMakeRect(1, 2, [self bounds].size.width-3.0,
[self bounds].size.height-7.0);

[[NSColor whiteColor] set];

[[NSBezierPath bezierPathWithRoundedRect:whiteFrame xRadius:8.6
yRadius:8.6] fill];


NSFont *stringFont = [NSFont fontWithName:@"Lucida Grande" size:18.0];


if ([[self stringValue] length] == 0) {

NSColor *txtColor = [NSColor grayColor];

NSDictionary *placeHolderDict = [NSDictionary


dictionaryWithObjectsAndKeys:txtColor,
NSForegroundColorAttributeName,stringFont,NSFontAttributeName,

 nil];


placeHolderString = [[NSAttributedString alloc]

 initWithString:[[self cell] placeholderString]
attributes:placeHolderDict];

[placeHolderString drawAtPoint:NSMakePoint(10.0,0.0)];

}

else {

NSColor *txtColor = [NSColor blackColor];

NSDictionary *txtDict = [NSDictionary

 dictionaryWithObjectsAndKeys:txtColor,
NSForegroundColorAttributeName,stringFont,NSFontAttributeName,

 nil];


placeHolderString = [[NSAttributedString alloc]

 initWithString:[self stringValue]
attributes:txtDict];

[placeHolderString drawAtPoint:NSMakePoint(6.0,4.0)];

}


}


But I am facing two problems:


First Problem: When a text field is selected, it is showing overlapping
white edges over round corners as shown in below image:


http://i.stack.imgur.com/8NJHW.png


Second Problem: When cursor is in textField1 and I am pressing tab key, it
is not moving to textField2 though in IB I have binded next key view of
textField1 as textField2.


Can any one suggest me some solution for above problems?


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: NSTextField subclass not working properly

2012-01-02 Thread Seth Willits
On Jan 2, 2012, at 10:35 PM, Devarshi Kulshreshtha wrote:

> First Problem: When a text field is selected, it is showing overlapping
> white edges over round corners as shown in below image:

That's the field editor drawing its background. Tweak it in 
setUpFieldEditorAttributes:


--
Seth Willits




___

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


File UTI on 10.6.8

2012-01-02 Thread Martin Hewitson
Dear list,

I want to check if a file extension is registered as a text file. So I made a 
little category method on NSString like this:

- (BOOL)isText
{  
  BOOL fileIsText = NO;

  CFStringRef fileExtension = (CFStringRef) self;
  CFStringRef fileUTI = 
UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, 
fileExtension, NULL);
  if (UTTypeConformsTo(fileUTI, kUTTypeText)) {
fileIsText = YES;
  }  
  CFRelease(fileUTI);
  
  return fileIsText;  
}

This works fine on 10.7. On 10.6.8 when 

self = @"tex"

this returns NO and fileUTI is dyn.age81k3p2.

Anybody got an idea what this dyn.* means?

Cheers,

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