NSPanel and NSWindowController

2010-06-24 Thread Daniel Káčer
Hi all,

i have created NSPanel in NIB file, for controlling this NSPanel i have also 
controller and i need in this controller handling close event this NSPanel. 
Which method is for this thing usable ?  
This window (NSPanel) contain configuration preferences in my application and 
on close this Preference window i need store all configuration values for my 
application.

regards
Donald___

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


Get my custom object from NSDictionary variable

2010-03-04 Thread Daniel Káčer

Hi,

i solve the following problem:

a add my custom object into NSDictionary variable in my application  
with following code:


[myDictionary setObject:[[ComplexObject alloc] initWithFrom:_tempFrom  
pairTo:string] forKey:[NSString stringWithFormat:@%d, [myDictionary  
count]]];


.. it seems, that this work correctly ..

but .. when i will retrieve value from my custom object from this  
NSDictionary variable, there is some issue ... and i don't know, what  
i do wrongly in this case ...


int iRandom = arc4random() % ([myDictionary count] - 1);
ComplexObject* compObj = [myDictionary objectForKey:[NSString  
stringWithFormat:@%d, iRandom]];

NSString* sText = [compObj valueFrom];   --- on this line is some issue

-
This is interface of my custom object:

@interface ComplexObject : NSObject
NSString* sValueFrom;
NSString* sValueTo;

-(ComplexObject*) initWithFrom:(NSString*)_sValueFrom pairTo: 
(NSString*)_sValueTo;

-(NSString*) valueFrom;
-(NSString*) valueTo;
@end

and this is implementatio of my custom object:
@implementation ComplexObject

- (NSString*) valueFrom {
return sValueFrom;
}

- (NSString*) valueTo {
return sValueTo;
}

- (ComplexObject*)initWithFrom:(NSString*)_sValueFrom pairTo: 
(NSString*)_sValueTo {

self = [super init];

if (self) {
sValueFrom = _sValueFrom;
sValueTo = _sValueTo;
}
return self;
}

@end

___

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: Get my custom object from NSDictionary variable

2010-03-04 Thread Daniel Káčer

thank you very much ...
This was the problem !




On Mar 5, 2010, at 0:57 , Thomas Wetmore wrote:

You need to retain your member variables in the initializer.

On Mar 4, 2010, at 6:48 PM, Daniel Káčer wrote:

- (ComplexObject*)initWithFrom:(NSString*)_sValueFrom pairTo: 
(NSString*)_sValueTo {

  self = [super init];

  if (self) {
  sValueFrom = _sValueFrom;  should be sValueFrom =  
[_sValueFrom retain];

  sValueTo = _sValueTo;  similarly here...
  }
  return self;
}



___

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


Store more complex values into NSDictionary

2010-02-25 Thread Daniel Káčer

Hi,

i need help with solution about store more complex values into  
NSDictionary.

I have following data which i need store in NSDictionary:

value1:@A1 value2:@B1 key:1
value1:@A2 value2:@B2 key:2
value1:@A3 value2:@B3 key:3
etc.

What is the ideal solution for this my case ?

thnx
Donald
___

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: Store more complex values into NSDictionary

2010-02-25 Thread Daniel Káčer
Ok, this good idea .. but which container contains 2 values ? ...  
Array is one dimensional container, set also one dimensional and  
dictionary is key based container .. so value with key ..

there i know only about solution NSDictionary with my custom class

[NSDictionary addObject:myClass forKey:[NSNumber numberWithInteger:1]]

or NSDictionary in combination with some struct.

[NSDictionary addObject:myStruct forKey:[NSNumber numberWithInteger:1]]

but I would like to know whether exist any more elegant solution ...


Donald




On Feb 26, 2010, at 0:12 , Greg Parker wrote:

On Feb 25, 2010, at 2:59 PM, Dave Carrigan wrote:

On Feb 25, 2010, at 2:51 PM, Daniel Káčer wrote:


i need help with solution about store more complex values into  
NSDictionary.

I have following data which i need store in NSDictionary:

value1:@A1 value2:@B1 key:1
value1:@A2 value2:@B2 key:2
value1:@A3 value2:@B3 key:3
etc.

What is the ideal solution for this my case ?


Create a class to represent your complex values and store instances  
of that class in the dictionary.


Another option: put the values in some container (array or set or  
dictionary), and set the container as the dictionary's value. This is  
how plists and user defaults work. It does get messy fast, though, in  
which case you want the more rigid structure of a real class.



--
Greg Parker gpar...@apple.com Runtime Wrangler



___

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: Store more complex values into NSDictionary

2010-02-25 Thread Daniel Káčer

thus more to i think over, I start giving you the truth ..

that this solution is basically what I need .. :)

NSDictionary *values = [NSDictionary  
dictionaryWithObjectsAndKeys:@A1, @subKey1, @B1, subKey2, nil];
NSDictionary *keyedValues = [NSDictionary  
dictionaryWithObjectsAndKeys:values, @1, nil];





On Feb 26, 2010, at 0:33 , Greg Parker wrote:

On Feb 25, 2010, at 3:25 PM, Daniel Káčer wrote:
Ok, this good idea .. but which container contains 2 values ? ...  
Array is one dimensional container, set also one dimensional and  
dictionary is key based container .. so value with key ..

there i know only about solution NSDictionary with my custom class


You store multiple values in an array, then store that array in a  
dictionary. Basically, you're using an array object instead of an  
object of a custom class.


Something like this:

   NSArray *array = [NSArray arrayWithObjects:@MyValue1,  
@MyValue2, nil];

   [myDict addObject:array forKey:@MyKey];

You'd fetch individual values like this:

   NSString *value1 = [[myDict objectForKey:@MyKey] objectAtIndex:0];
   NSString *value2 = [[myDict objectForKey:@MyKey] objectAtIndex:1];
   // value1 is @MyValue1, value2 is @MyValue2.


--
Greg Parker gpar...@apple.com Runtime Wrangler



___

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


How do I get keyboard events in an NSStatusWindowLevel window while my application is not frontmost?

2010-02-18 Thread Daniel Káčer
After creating a translucent NSPanel and I want to get keyboard events  
in this window. It seems that there are only keyboard events when my  
application is the active application while I want keyboard events  
even when my application isn't active but the window is visible.


Basically I want behavior like that provided by the Quicksilver  
application.


Does anybody have any hints on how to do this?



Regards

Donald
___

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

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

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

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


Re: How do I get keyboard events in an NSStatusWindowLevel window while my application is not frontmost?

2010-02-18 Thread Daniel Káčer

thank you very much ... your second hint was what I needed to know :)

Donald


On Feb 18, 2010, at 19:03 , Jens Alfke wrote:


On Feb 18, 2010, at 9:22 AM, Daniel Káčer wrote:

After creating a translucent NSPanel and I want to get keyboard  
events in this window. It seems that there are only keyboard events  
when my application is the active application while I want keyboard  
events even when my application isn't active but the window is  
visible.
Basically I want behavior like that provided by the Quicksilver  
application.


If you want to handle a particular keystroke (like Quicksilver's Ctrl- 
Space) no matter what app is active, define a system hot-key. There is  
sample code showing how to do this, but I don't know an exact name or  
URL.


Once your hot key has triggered, call [NSApp  
activateIgnoringOtherApps: YES] and [myWindow makeKeyAndOrderFront:  
nil], so your window will have focus and will receive typing.


—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: NSPanel and runModalForWindow: problems

2010-02-15 Thread Daniel Káčer
Thank you, but maybe i have not describe it quite right, but my issue  
is, that in first calling of  showModal function is my NSPanel  
displayed top of all windows on my desktop and clicking on any window  
will this window not overlap my NSPanel and will remain this my panel  
still on top. This is correct functionality ! :)  But .. this function  
showModal is called multiple times during runnig my application, and  
this NSPanel is multiple showed and closed. But only first calling of  
showModal function will showing my panel still on top of all windows  
on desktop, all other calls this function, during running my  
application, show my panel so, that is no problem overlap him with  
clicking to another window and panel will not remain on top. :(


thnx
Daniel

On Feb 15, 2010, at 17:19 , Keary Suska wrote:

On Feb 13, 2010, at 7:53 AM, Daniel Káčer wrote:


I have a NSPanel that is opened like Modal panel:

-(void) showModal {
   [NSApp runModalForWindow: myWindow];
}

and is closed with event click on button that is allocated on this  
NSPanel:


-(IBAction)delayWindow:(id)sender {
  [NSApp abortModal];
//[myWindow orderOut: self];
  [myWindow close];
}

First calling of runModalForWindow: works fine and NSPanel is in  
modal status but after calling delayWindow and after then second  
calling of  showModal is NSPanel correctly showed but is not in  
Modal status :(
What i do wrongly and why is not my NSPanel in Modal status after  
second, third etc. calling of showModal ?


The proper way to end a modal session within the modal event loop is  
to use -stopModal or -stopModalWithCode: . Try that and keep the - 
orderOut call (not because it is necessary, just that it is a good  
practice for windows you know you will re-use without re-loading).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: NSPanel and runModalForWindow: problems

2010-02-15 Thread Daniel Káčer

Ok, so .. at the end I managed to find the correct solution

-(void) showModal
[myWindow setLevel: NSStatusWindowLevel];
[myWindow center];
[myWindow orderFront: self];
}

-(IBAction)delayWindow:(id)sender {
[myWindow orderOut: self];
}

also thank those Keary Suska, that he brought me back on track :)

Daniel



On Feb 15, 2010, at 17:19 , Keary Suska wrote:

On Feb 13, 2010, at 7:53 AM, Daniel Káčer wrote:


I have a NSPanel that is opened like Modal panel:

-(void) showModal {
   [NSApp runModalForWindow: myWindow];
}

and is closed with event click on button that is allocated on this  
NSPanel:


-(IBAction)delayWindow:(id)sender {
  [NSApp abortModal];
//[myWindow orderOut: self];
  [myWindow close];
}

First calling of runModalForWindow: works fine and NSPanel is in  
modal status but after calling delayWindow and after then second  
calling of  showModal is NSPanel correctly showed but is not in  
Modal status :(
What i do wrongly and why is not my NSPanel in Modal status after  
second, third etc. calling of showModal ?


The proper way to end a modal session within the modal event loop is  
to use -stopModal or -stopModalWithCode: . Try that and keep the - 
orderOut call (not because it is necessary, just that it is a good  
practice for windows you know you will re-use without re-loading).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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


NSPanel and runModalForWindow: problems

2010-02-14 Thread Daniel Káčer

I have a NSPanel that is opened like Modal panel:

-(void) showModal {
 [NSApp runModalForWindow: myWindow];
}

and is closed with event click on button that is allocated on this  
NSPanel:


-(IBAction)delayWindow:(id)sender {
[NSApp abortModal];
  //[myWindow orderOut: self];
[myWindow close];
}

First calling of runModalForWindow: works fine and NSPanel is in modal  
status but after calling delayWindow and after then second calling of   
showModal is NSPanel correctly showed but is not in Modal status :(
What i do wrongly and why is not my NSPanel in Modal status after  
second, third etc. calling of showModal ?


thnx
Donald
___

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