Re: NSTableView - Drag/Drop not working

2011-10-09 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/7/11 10:25 PM, GW Rodriguez wrote:
 I have gone through many different threads on this, read the docs
 and went over a few example projects.  For some reason I cannot
 get reordering via drag and drop to work.  I have even created a
 new project with only a NSTableView with one column and pasted code
 from a working example and it still wont work.
 
 My guess is my error is somewhere around the
 registerForDraggedTypes method because I cannot even start the
 drag.  It only start to highlight multiple selections.  I dont
 fully understand that method and I should also note that all the
 example projects are document based projects and mine is not.

Code would really help here.

To get to the point where dragging *begins* you need to minimally do
the following:

1) Have a data source (an object that, in 10.6 and newer, conforms to
NSTableViewDataSource) properly set for your table.  I repeat: make
sure your data source is assigned to the object in which you are
implementing your dragging methods.

2) In your data source, return YES from
–tableView:writeRowsWithIndexes:toPasteboard:.

If you do this, you will be able to start a drag (but won't be able to
drop it anywhere yet).

Note what I did not mention:

* Whether the app is document based is irrelevant.

* You DON'T need to call -registerForDraggedTypes:.  This method is
used to set which pasteboard types the view potentially _accepts_ from
a drag.  If you don't register one or more types, the table view won't
let you drop a row that you are dragging, but it will let you begin a
dragging session.

* You DON'T need to implement anything other than a return in
–tableView:writeRowsWithIndexes:toPasteboard:.  Of course, if you
don't you won't actually be storing any pasteboard data, so the drag
will be useless - but the drag will still visually begin.

So, check on your implementation of the two steps listed earlier.  You
might consider breaking on
–tableView:writeRowsWithIndexes:toPasteboard: to make sure it's
getting called.

After you have nailed that down and can see a drag begin, you will
need to flesh out the full dragging procedure.  In particular:

1) DO call -registerForDraggedTypes: and give it an array of UTIs; for
a table view, this may be a single custom UTI you define for internal
use and which you will use in the dragging methods where required.

2) DO fully implement –tableView:writeRowsWithIndexes:toPasteboard:.
For row reordering purposes, it may be as simple as:

- - (BOOL)tableView:(NSTableView *)tableView
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard *)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray
arrayWithObject:MyAwesomeCustomUTIStringThatIDeclaredSomewhere]
owner:self];
[pboard setData:data
forType:MyAwesomeCustomUTIStringThatIDeclaredSomewhere];
return YES;
}

3) DO implement
- -tableView:validateDrop:proposedRow:proposedDropOperation:, most
likely returning NSDragOperationMove for a row reordering operation.

4) DO implement -tableView:acceptDrop:row:dropOperation: to reorder
the rows and/or update the model (if appropriate), typically returning
YES if it's a simple row reordering.

Good luck - feel free to post a link to your sample project if you
can't get it to work.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6RZ9sACgkQaOlrz5+0JdVHhgCfcYVJb9z4LPGSYse8lqlL1j9Z
Y84AnjBIrGlea59mWTKqLnnVejOBxXUg
=YAKg
-END PGP SIGNATURE-
___

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: dataWithBytesNoCopy:length:freeWhenDone

2011-10-09 Thread silverdr

On 2011-10-09, at 05:50, Ken Thomases wrote:

 I'd guess that, with the 'NO' parameter, NSMutableData copies the data 
 anyway.
 
 This is actually documented.  In the Binary Data Programming Guide, in the 
 article Working With Binary Data[1], it says:
 
 However, if you create an NSData object with one of the methods whose name 
 includes NoCopy (such as dataWithBytesNoCopy:length:), the bytes are not 
 copied. Instead, the data object takes ownership of the bytes passed in as 
 an argument and frees them when the object is released. (NSMutableData 
 responds to these methods, too, but the bytes are copied anyway and the 
 buffer is freed immediately.)

I see. I even read this document but it seems I was reading too fast and I 
missed the part in parentheses. Thank you for pointing out. Although I believe 
this should rather be placed in the class documentation..

Regards,

-- 
SD!___

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: dataWithBytesNoCopy:length:freeWhenDone

2011-10-09 Thread silverdr

On 2011-10-09, at 05:05, Quincey Morris wrote:

 What am I doing wrong? Shouldn't the instance created using 
 dataWithBytesNoCopy:length:freeWhenDone simply hold the same bytes as 
 the originally provided ones? 
 
 Presumably you're using 'dataWithBytesNoCopy:length:freeWhenDone:NO', since 
 'dataWithBytesNoCopy:length:freeWhenDone:YES' would be invalid in the 
 scenario you describe. 

Right.

 I'd guess that, with the 'NO' parameter, NSMutableData copies the data 
 anyway. Mutating the data would become treacherous if the underlying memory 
 doesn't belong to the NSMutableData object that's trying to mutate it.

That would explain, although the NoCopy is in that case moot then.

 So, really all you could do is change individual bytes, and you scarcely need 
 subsidiary NSMutableData objects for that -- simple C pointers would do. 
 (Note, however, that you'd be using interior pointers, which would open you 
 up to a range of possible memory management issues, depending on which memory 
 model you're using.)

I see. And agree.

 What are you trying to get the subsidiary NSMutableData objects to do for you 
 that C pointers won't?

No - I mean I can do all those things I need to do by laying a set of structs 
over the array of bytes I receive within the original NSMutableData instance. 
But what I tried to achieve was to do it somewhat more OO, although sharing 
the payload between various instances seems to be contradicting it ;-) And I 
also wanted to minimise the overhead of passing and copying large amounts of 
data around in order to do the manipulations, while at the end having a need to 
reconstruct the original stream (file format) from multiple objects.

Regards,

-- 
SD!___

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: return NO in tableViewSelectionDidChange: disables button cell

2011-10-09 Thread Michael Hanna
Was exactly what I needed! Thanks,

Michael

On Sat, Oct 8, 2011 at 11:20 PM, Quincey Morris 
quinceymor...@rivergatesoftware.com wrote:

 On Oct 8, 2011, at 20:10 , Michael Hanna wrote:

 On Mac OS X 10.6.8, in an NSTableView I have a column that contains
 nsbuttoncell class. Row selection isn't useful in my application but doing:

 - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
 {
  return NO;
 }

 means that there is no response whenever I click on the button cell(it
 doesn't fire).

 How do I get that button cell to send it's action and have no row selection
 in the table view at the same time? I'm sure there is a way to do this.


 See the 'tableView:shouldTrackCell:forTableColumn:row:' delegate method.

 The reference documentation for this method includes this discussion:

 Normally, only selectable or selected cells can be tracked. If you
 implement this method, cells which are not selectable or selected can be
 tracked, and vice-versa.

 For example, this allows you to have an NSButtonCell in a table which does
 not change the selection, but can still be clicked on and tracked.


 Does that sound relevant to your situation?



___

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


NSTableView data source issue - code moving from xcode 3 to xcode 4

2011-10-09 Thread Peter Hudson
Hi There

For a long time ( in xcode 3 )  when I want to access a table view data source 
( in the sub class code for the table view ) I simply called  [self  dataSource]
I would then call methods declared and implemented on the class which I new to 
be the datasource.  This worked fine.

In xcode 4 ( sdk 10.7 ) the compiler throws a semantic warning when I do this.  
It complains that the return value from [self  dataSource]   is ignorant of the 
methods I am calling on it.

I have found a solution in overriding the dataSource  method in my table view 
subclass and simply returning [self  dataSource]   cast to the class which I 
know the datasource to be.  

This feels evil.  Is there a nicer way to do this ?

Peter
___

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: NSTableView data source issue - code moving from xcode 3 to xcode 4

2011-10-09 Thread Jens Alfke

On Oct 9, 2011, at 9:41 AM, Peter Hudson wrote:

 For a long time ( in xcode 3 )  when I want to access a table view data 
 source ( in the sub class code for the table view ) I simply called [self  
 dataSource]
 I would then call methods declared and implemented on the class which I new 
 to be the datasource.  This worked fine.
 
 In xcode 4 ( sdk 10.7 ) the compiler throws a semantic warning when I do 
 this.  It complains that the return value from [self  dataSource] is ignorant 
 of the methods I am calling on it.

This probably happened because you changed the base SDK from 10.5 to 10.6+.

In the 10.6 SDK Apple introduced @protocols for most delegates/data-sources/etc 
instead of making them “informal protocols” aka categories. So the 
-delegate/-dataSource properties now no longer return an untyped “id” but a 
typed protocol reference like “idNSTableViewDataSource”. The benefit is that 
the compiler can now type-check it. The drawback is that the compiler will now 
type-check it :)

If you know your data source is of, say, class MyDataSource, then all you need 
to do is add a cast:

[(MyDataSource*)[self dataSource] myCustomMethod]

—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: NSTableView data source issue - code moving from xcode 3 to xcode 4

2011-10-09 Thread Fritz Anderson
On 9 Oct 2011, at 11:41 AM, Peter Hudson wrote:

 I have found a solution in overriding the dataSource  method in my table view 
 subclass and simply returning [self  dataSource]   cast to the class which I 
 know the datasource to be. 

Why override the method, when all you can just cast the return value?

@implementation MyTableViewClass

- (void) myMethod
{
DataSourceClass * aVar = (DataSourceClass *) [self dataSource];
// ...
}
// ...
@end

You will have to make sure that DataSourceClass declares it complies with 
NSTableViewDataSource.

— F

___

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: dataWithBytesNoCopy:length:freeWhenDone

2011-10-09 Thread Quincey Morris
On Oct 9, 2011, at 05:44 , silve...@wfmh.org.pl wrote:

 But what I tried to achieve was to do it somewhat more OO, although sharing 
 the payload between various instances seems to be contradicting it ;-) 

Not at all. Sharing the payload is neither a problem nor wrong, but trying to 
take a shortcut by using NSMutableData to do it isn't the solution.

Don't be afraid of writing your own class for this. You need to encapsulate the 
underlying NSMutableData object, a starting offset and a byte length, and you 
need to be able to retrieve a pointer (maybe a structure pointer rather than a 
void*) to the corresponding mutable data fragment. Sounds pretty 
straightforward.


___

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: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-09 Thread Jerry Krinock

On 2011 Oct 08, at 21:12, Stephen J. Butler wrote:

 What's wrong with +[NSDate distantFuture]?

Nothing.  It's only [NSDate -dateWithTimeIntervalSinceNow:FLT_MAX] which 
sometimes gives unexpected results.

___

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


Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
Is there any code which can *click* a menu, to give it keyboard focus, so that 
the user may then select an item in the menu using arrow keys?

Thanks a bunch!

Jerry

___

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: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-09 Thread Stephen J. Butler
On Sun, Oct 9, 2011 at 1:51 PM, Jerry Krinock je...@ieee.org wrote:

 On 2011 Oct 08, at 21:12, Stephen J. Butler wrote:

 What's wrong with +[NSDate distantFuture]?

 Nothing.  It's only [NSDate -dateWithTimeIntervalSinceNow:FLT_MAX] which 
 sometimes gives unexpected results.

It's not, at least not on 10.6 with Xcode 3.2.5. This program...


#import Foundation/Foundation.h

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog( @distantFuture: %@, [NSDate distantFuture] );
NSLog( @FLT_MAX: %@, [NSDate dateWithTimeIntervalSinceNow:FLT_MAX] );

[pool drain];
return 0;
}


Gives the output (in 32 and 64 bit):


2011-10-09 14:46:41.639 Untitled[60937:a0f] distantFuture: 4000-12-31
18:00:00 -0600
2011-10-09 14:46:41.640 Untitled[60937:a0f] FLT_MAX: 5828963-12-19
18:00:00 -0600

I think you'll find distantFuture much less buggy than your solution,
seeing as how it isn't going to overflow or run into boundary
situations.
___

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: Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
Update: I'm borrowing the mouse using CGEventCreateMouseEvent().  It seems 
like it might work, but sure seems like a kludge, and many lines of code to do 
something very simple.

Any better ideas would be appreciated.

On 2011 Oct 09, at 12:31, Jerry Krinock wrote:

 Is there any code which can *click* a menu, to give it keyboard focus, so 
 that the user may then select an item in the menu using arrow keys?

___

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: Give a menu keyboard focus - in code

2011-10-09 Thread Jerry Krinock
OK, the CGEventCreateMouseEvent() I described in my previous message seems to 
work, except for one detail.  How to I find the location of, in particular, a 
Status Menu item, in CG global coordinates?  It looks like that's the hardest 
part!

Jerry

On 2011 Oct 09, at 14:16, Jerry Krinock wrote:

 Update: I'm borrowing the mouse using CGEventCreateMouseEvent().  It seems 
 like it might work, but sure seems like a kludge, and many lines of code to 
 do something very simple.
 
 Any better ideas would be appreciated.
 
 On 2011 Oct 09, at 12:31, Jerry Krinock wrote:
 
 Is there any code which can *click* a menu, to give it keyboard focus, so 
 that the user may then select an item in the menu using arrow keys?


___

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


NSComboBoxCell AutoComplete

2011-10-09 Thread livinginlosangeles
I have an NSComboBox bound to the selection of an NSArrayController. The bound 
object is an NSDictionary.  I use an NSValueTransfomer to represent the 
NSDictionary. The ValueTransformer gives me the dictionary's summary property 
which is useful for people choosing the appropriate NSDictionary from the 
array. I have set up the NSComboBox to use a datasource for custom 
autocompletion. I need case insensitive autocompletion which does not come 
straight of the box. Whenever I star typing in my NSComboBox, I get an 
-[NSDictionary length] exception. The NSComboxCell is trying to complete by 
sending a length request to the bound object, not through the transformer. Is 
there a way around this? The calling method before the exception is 
[NSComboBoxCell _completeNoRecursion]. Thanks,

Patrick
___

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


Screen Coordinates of Menu. Use CTM? (was: Give menu keyboard focus)

2011-10-09 Thread Jerry Krinock
I changed the subject line because if I could just get the screen coordinates 
of my Status Item, my kludge for giving it keyboard focus looks like it will 
work.

NSMenu inherits from NSObject, and as far as I can see give no clue regarding 
its location on the screen.  NSStatusItem and NSStatusBar are likewise mum.

However, the status item has an image.  I subclassed NSImage, found that 
-drawInRect:fromRect:operation:fraction:respectFlipped:hints: is invoked.  From 
reading the Cocoa Drawing Guide, it seems that the tx value of the current 
transformation matrix when this method is running is the x-coordinate that I'm 
looking for.  So I subclassed NSImage…

@implementation MyLocatableImage

- (void)drawInRect:(NSRect)dstSpacePortionRect
  fromRect:(NSRect)srcSpacePortionRect
 operation:(NSCompositingOperation)op
  fraction:(CGFloat)requestedAlpha
respectFlipped:(BOOL)respectContextIsFlipped
 hints:(NSDictionary *)hints {
NSGraphicsContext* nsGraphicsContext = [NSGraphicsContext currentContext] ;
CGContextRef aContext = [nsGraphicsContext graphicsPort] ;
CGAffineTransform ctm = CGContextGetCTM(aContext) ;
NSLog(@The ctm: %f %f %f %f %f %f, ctm.a , ctm.b , ctm.c , ctm.d , ctm.tx 
, ctm.ty) ;
[super drawInRect:dstSpacePortionRect
 fromRect:srcSpacePortionRect
operation:op
 fraction:requestedAlpha
   respectFlipped:respectContextIsFlipped
hints:hints] ;
}

@end

Unfortunately, the matrix elements are NSLogged as:
  1.00 0.00 -0.00 1.00 0.00 22.00

which is obviously not what I'm looking for, since the the x-coordinate of my 
status item is about 850.

The two 'Rect' parameters of that method give similar useless local coordinates.

Is there any way to get the global/screen coordinates of a menu, an 
NSStatusItem in particular?

Thanks,

Jerry

On 2011 Oct 09, at 14:41, Jerry Krinock wrote:

 OK, the CGEventCreateMouseEvent() kludge I described in my previous message 
 seems to work, except for one detail.  How do I find the location of, in 
 particular, a Status Menu item, in CG global coordinates?  It looks like 
 that's the hardest part!
 
 Jerry
 
 On 2011 Oct 09, at 14:16, Jerry Krinock wrote:
 
 Update: I'm borrowing the mouse using CGEventCreateMouseEvent().  It seems 
 like it might work, but sure seems like a kludge, and many lines of code to 
 do something very simple.
 
 Any better ideas would be appreciated.
 
 On 2011 Oct 09, at 12:31, Jerry Krinock wrote:
 
 Is there any code which can *click* a menu, to give it keyboard focus, so 
 that the user may then select an item in the menu using arrow keys?

___

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: Screen Coordinates of Menu. Use CTM? (was: Give menu keyboard focus)

2011-10-09 Thread Graham Cox
This all sounds like a generally terrible idea.

Have you checked to see whether the Accessibility APIs can give you what you 
want?

If it's for some other purpose than accessibility, sounds like you're walking 
the slippery slope to hell…. ;)


--Graham




On 10/10/2011, at 1:26 PM, Jerry Krinock wrote:

 I changed the subject line because if I could just get the screen coordinates 
 of my Status Item, my kludge for giving it keyboard focus looks like it will 
 work.
 
 NSMenu inherits from NSObject, and as far as I can see give no clue regarding 
 its location on the screen.  NSStatusItem and NSStatusBar are likewise mum.
 
 However, the status item has an image.  I subclassed NSImage, found that 
 -drawInRect:fromRect:operation:fraction:respectFlipped:hints: is invoked.  
 From reading the Cocoa Drawing Guide, it seems that the tx value of the 
 current transformation matrix when this method is running is the x-coordinate 
 that I'm looking for.  So I subclassed NSImage…
 
 @implementation MyLocatableImage
 
 - (void)drawInRect:(NSRect)dstSpacePortionRect
  fromRect:(NSRect)srcSpacePortionRect
 operation:(NSCompositingOperation)op
  fraction:(CGFloat)requestedAlpha
respectFlipped:(BOOL)respectContextIsFlipped
 hints:(NSDictionary *)hints {
NSGraphicsContext* nsGraphicsContext = [NSGraphicsContext currentContext] ;
CGContextRef aContext = [nsGraphicsContext graphicsPort] ;
CGAffineTransform ctm = CGContextGetCTM(aContext) ;
NSLog(@The ctm: %f %f %f %f %f %f, ctm.a , ctm.b , ctm.c , ctm.d , 
 ctm.tx , ctm.ty) ;
[super drawInRect:dstSpacePortionRect
 fromRect:srcSpacePortionRect
operation:op
 fraction:requestedAlpha
   respectFlipped:respectContextIsFlipped
hints:hints] ;
 }
 
 @end
 
 Unfortunately, the matrix elements are NSLogged as:
  1.00 0.00 -0.00 1.00 0.00 22.00
 
 which is obviously not what I'm looking for, since the the x-coordinate of my 
 status item is about 850.
 
 The two 'Rect' parameters of that method give similar useless local 
 coordinates.
 
 Is there any way to get the global/screen coordinates of a menu, an 
 NSStatusItem in particular?

___

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: Screen Coordinates of Menu. Use CTM? (was: Give menu keyboard focus)

2011-10-09 Thread Seth Willits

Yeahh... What you did there was pretty nasty. :p

The status icon/view in the menu bar is in a window. You can thus get that 
window's coordinates by [[[statusItem view] window] frame]. This relies on how 
it's currently implemented, however I don't see it changing any time soon. 


--
Seth Willits







On Oct 9, 2011, at 7:47 PM, Graham Cox wrote:

 This all sounds like a generally terrible idea.
 
 On 10/10/2011, at 1:26 PM, Jerry Krinock wrote:
 
 Is there any way to get the global/screen coordinates of a menu, an 
 NSStatusItem in particular?


___

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


Give a menu keyboard focus – in code

2011-10-09 Thread Jerry Krinock

On 2011 Oct 09, at 19:47, Graham Cox wrote:

 This all sounds like a generally terrible idea.

I think that my purpose of making my Status Item accessible from the keyboard 
is quite noble, but I agree that the way I'm going about it is a terrible kludge

 Have you checked to see whether the Accessibility APIs can give you what you 
 want?

I'll look at the NSAccessibility protocol and read the Accessibility 
Programming Guidelines.  If there are any other documents in particular I 
should be reading, let me know

 If it's for some other purpose than accessibility

Well, I, and many users, even though we have functioning two hands, would 
really like to be able to  access Status Items without using the mouse.  
Unfortunately, the built-in F8 keyboard shortcut to Focus on Status Items 
only cycles through the *Apple* status items.  (Filed a few weeks ago: Apple 
Bug ID #10122120).

___

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: NSComboBoxCell AutoComplete

2011-10-09 Thread Quincey Morris
On Oct 9, 2011, at 17:18 , livinginlosange...@mac.com wrote:

 I have an NSComboBox bound to the selection of an NSArrayController. The 
 bound object is an NSDictionary.  I use an NSValueTransfomer to represent the 
 NSDictionary. The ValueTransformer gives me the dictionary's summary property 
 which is useful for people choosing the appropriate NSDictionary from the 
 array. I have set up the NSComboBox to use a datasource for custom 
 autocompletion. I need case insensitive autocompletion which does not come 
 straight of the box. Whenever I star typing in my NSComboBox, I get an 
 -[NSDictionary length] exception. The NSComboxCell is trying to complete by 
 sending a length request to the bound object, not through the transformer. Is 
 there a way around this? The calling method before the exception is 
 [NSComboBoxCell _completeNoRecursion]. Thanks,

There's not really enough information here to diagnose anything, except that 
you refer to choosing … from the array. That leads me to suspect you're 
(wrongly) trying to use the NSComboBox as a kind of menu. It's not -- it's a 
kind of text field, an editable one. What you're doing (it sounds like) is 
asking to edit the dictionary's summary property, which doesn't sound sensible, 
and trying to customize the autocompletion behavior is probably just making 
things worse.

If you're trying to let the user choose one of an existing array of things, use 
a NSPopUpButton instead, or some other variant of an actual menu. If you also 
want the user to type-select things, then consider using a NSTableView.


___

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


NSFont squashes my first two characters

2011-10-09 Thread Oron Cherry
I am trying to figure out why my string gets squashed sometimes in the first 
two characters.

Here's what I get: Here's what I get: 
http://a3.l3-images.myspacecdn.com/images02/127/4715903defac43d196c873a29fd6527d/l.jpg

Here's what I wish I could get: Here's what I wish I could get: 
http://a1.l3-images.myspacecdn.com/images02/148/6699adf99ae949428b97cfa74ae9e1a9/l.jpg

The following code shows the basics of what I am writing:
m_attribs is a NSMutableDictionary
...
font = [NSFont fontWithName:@Geneva size:10];
[m_attribs setObject:font forKey:NSFontAttributeName];
...
[m_string drawAtPoint:NSMakePoint (0,0) withAttributes:m_attribs];

Geneva font gives the problem shown in the above image. Other fonts such as 
Helvetica are fine.

What can be missing to make the string drawn with enough space between the 
first two characters and the rest? I tried to set NSFontFixedAdvanceAttribute, 
but then I get an unnatural spacing between all characters.

Thanks, Mr. C.
___

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: Give a menu keyboard focus – in code

2011-10-09 Thread John Joyce

On Oct 9, 2011, at 10:09 PM, Jerry Krinock wrote:

 
 On 2011 Oct 09, at 19:47, Graham Cox wrote:
 
 This all sounds like a generally terrible idea.
 
 I think that my purpose of making my Status Item accessible from the keyboard 
 is quite noble, but I agree that the way I'm going about it is a terrible 
 kludge
 
 Have you checked to see whether the Accessibility APIs can give you what you 
 want?
 
 I'll look at the NSAccessibility protocol and read the Accessibility 
 Programming Guidelines.  If there are any other documents in particular I 
 should be reading, let me know
 
 If it's for some other purpose than accessibility
 
 Well, I, and many users, even though we have functioning two hands, would 
 really like to be able to  access Status Items without using the mouse.  
 Unfortunately, the built-in F8 keyboard shortcut to Focus on Status Items 
 only cycles through the *Apple* status items.  (Filed a few weeks ago: Apple 
 Bug ID #10122120).
For this reason, any menu item with a name can be assigned a keyboard shortcut 
in OS X System Preferences by the user.


___

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: Screen Coordinates of Menu. Use CTM? (was: Give menu keyboard focus)

2011-10-09 Thread Jerry Krinock

On 2011 Oct 09, at 19:57, Seth Willits wrote:

 The status icon/view in the menu bar is in a window. You can thus get that 
 window's coordinates by [[[statusItem view] window] frame].

Thank you, Seth.  I wish it were so.

But [statusItem view] returns nil for me.  And the documentation explains that 
the 'view' of a status item is an optional custom view which overrides the 
regular menu behavior.

___

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


Xcode 3 to 4 - CoreData in IB

2011-10-09 Thread GW Rodriguez
Back in Xocde 3 you could drag an entity into IB.  With Xcode 4 you can no 
longer do this.  I have found a way to do the exact same thing in IB but miss 
the ease of use of dragging an entity into IB.  

Does anyone know if the IB team will be bringing this back in future releases 
of xcode?  

PS - I currently have xcode 4.1

GW
___

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: Screen Coordinates of Menu. Use CTM? (was: Give menu keyboard focus)

2011-10-09 Thread Graham Cox
You could use [NSMenuItem setView:] with a temporary view which would 
presumably be hooked up to the underlying window internally, grab its window, 
then set it back to nil???

A hack, but not as bad as the original one :)

--Graham


On 10/10/2011, at 4:41 PM, Jerry Krinock wrote:

 
 On 2011 Oct 09, at 19:57, Seth Willits wrote:
 
 The status icon/view in the menu bar is in a window. You can thus get that 
 window's coordinates by [[[statusItem view] window] frame].
 
 Thank you, Seth.  I wish it were so.
 
 But [statusItem view] returns nil for me.  And the documentation explains 
 that the 'view' of a status item is an optional custom view which overrides 
 the regular menu behavior.
 
 ___
 
 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/graham.cox%40bigpond.com
 
 This email sent to graham@bigpond.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