Re: Editing NSOutlineView Group Item

2014-11-05 Thread Quincey Morris
On Nov 4, 2014, at 14:39 , Luther Baker lutherba...@gmail.com wrote:
 
 I've created a project on github that essentially duplicates the problem I'm 
 having.
 
 $ git clone https://github.com/EffectiveProgramming/LBOutlineViewDemo.git 
 https://github.com/EffectiveProgramming/LBOutlineViewDemo.git


I don’t see anything in it that should prevent the reload from working, so I 
don’t know what else to suggest except submit this project as a bug report.

OTOH, based on the direction that you seem to be heading, I’d suggest you might 
do better to use bindings (from your table cell view subviews to the table cell 
view’s objectValue property, which would be set to the custom list item) and 
KVC to get the outline view to update, rather than using reload. That approach 
doesn’t answer the issue you’ve run into, but it might make it moot.



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: dispatch_source does not work

2014-11-05 Thread Gerriet M. Denkmann

 On 5 Nov 2014, at 14:08, Peter magn...@web.de wrote:
 
 http://stackoverflow.com/questions/12343833/cocoa-monitor-a-file-for-modifications/26304208#26304208
 
 has some info on this.

Thanks a lot. Got it working now.

Mit freundlichen Grüßen

Gerriet.

 
 ___ Peter Hartmann 
 
 mailto:hphartm...@justmail.de
 
 
 Am 05.11.2014 um 07:50 schrieb Gerriet M. Denkmann gerr...@mdenkmann.de:
 
 I want to monitor a file for changed content.
 Polling is generally not a good idea, so I tried dispatch_source.
 
 But it does not work.
 
 Here the code:
 
 static NSString *const kTestPath = @/tmp/a.test;   
 
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
 {
  const char *filename = kTestPath.fileSystemRepresentation;
  int fd = open(filename, O_RDONLY);
  fcntl(fd, F_SETFL, O_NONBLOCK);  
  uintptr_t fD = (uintptr_t)fd;
  dispatch_queue_t queue = 
 dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  const uint64_t flags = DISPATCH_VNODE_WRITE | DISPATCH_VNODE_LINK; 
  dispatch_source_t my_source = 
 dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fD, flags, queue);
  dispatch_source_set_event_handler(my_source, ^{ [self fileDidChange]; } 
 );
  dispatch_resume(my_source);
 }
 
 - (void)fileDidChange
 {
  NSLog(@%s,__FUNCTION__);  //  never seen
 }
 
 - (IBAction)buttonClicked: sender
 {
  static NSUInteger seqq = 0;
  seqq++;
  
  const char *stats_temp_file = /tmp/a.temp;
  FILE *fp = fopen(stats_temp_file, w);
  fprintf(fp, %lu\n, seqq);
  (void)fclose(fp);
  
  const char *filename = kTestPath.fileSystemRepresentation;
  int a = rename(stats_temp_file, filename);
 }
 
 What am I doing wrong? (Writing directly to kTestPath without rename() also 
 does not work).
 
 Gerriet.


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Editing NSOutlineView Group Item

2014-11-05 Thread Luther Baker
Thanks and thanks. I'll follow up on both your suggestions.

Again, many thanks for your time Quincey!

Luther


 On Nov 5, 2014, at 2:03 AM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:
 
 On Nov 4, 2014, at 14:39 , Luther Baker lutherba...@gmail.com wrote:
 
 I've created a project on github that essentially duplicates the problem I'm 
 having.
 
 $ git clone https://github.com/EffectiveProgramming/LBOutlineViewDemo.git
 
 
 I don’t see anything in it that should prevent the reload from working, so I 
 don’t know what else to suggest except submit this project as a bug report.
 
 OTOH, based on the direction that you seem to be heading, I’d suggest you 
 might do better to use bindings (from your table cell view subviews to the 
 table cell view’s objectValue property, which would be set to the custom list 
 item) and KVC to get the outline view to update, rather than using reload. 
 That approach doesn’t answer the issue you’ve run into, but it might make it 
 moot.
 
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Initializing Structures

2014-11-05 Thread Richard Charles
A fast and compact way to initialize a structure is to enclose the values in a 
pair of braces like this.

 NSRect rect = {{0,0},{80,20}};
 NSView *view = [[NSView alloc] initWithFrame:rect];

However a compiler error occurs if we try to initialize a struct with braces 
directly within an Objective-C message.

 NSView *view = [[NSView alloc] initWithFrame:{{0,0},{80,20}}];

Why does the compiler accept the first but not the second?

Richard Charles
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Initializing Structures

2014-11-05 Thread Greg Parker

 On Nov 5, 2014, at 2:03 PM, Richard Charles rcharles...@gmail.com wrote:
 
 A fast and compact way to initialize a structure is to enclose the values in 
 a pair of braces like this.
 
 NSRect rect = {{0,0},{80,20}};
 NSView *view = [[NSView alloc] initWithFrame:rect];
 
 However a compiler error occurs if we try to initialize a struct with braces 
 directly within an Objective-C message.
 
 NSView *view = [[NSView alloc] initWithFrame:{{0,0},{80,20}}];
 
 Why does the compiler accept the first but not the second?

The C language allows a struct variable to be initialized in its declaration 
using the brace syntax, but does not allow that form to be used anywhere else.

C99 adds this syntax (compound literal) that works anywhere:

NSView *view = [[NSView alloc] initWithFrame:(NSRect){{0,0},{80,20}}];


-- 
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Initializing Structures

2014-11-05 Thread Kyle Sluder
On Wed, Nov 5, 2014, at 04:11 PM, Greg Parker wrote:
 The C language allows a struct variable to be initialized in its
 declaration using the brace syntax, but does not allow that form to be
 used anywhere else.
 
 C99 adds this syntax (compound literal) that works anywhere:
 
 NSView *view = [[NSView alloc]
 initWithFrame:(NSRect){{0,0},{80,20}}];
 

The compound literal syntax is also a lot more flexible: it can
initialize members by name; they can be initialized out of order;
members in nested structs can be initialized directly; and all members
that are not initialized explicitly are initialized to zero.

What I'm saying is, it's really handy and you should look it up.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSImage glowing

2014-11-05 Thread Alex Kac
Yeah, I need to look at that original message. I’ve been doing iOS stuff for 
years and so OS X stuff is a bit foreign to me. I only hit the OS X stuff 
intermittently - i.e. when my team needs some specific UI stuff which is ironic 
in a way. We’re all iOS developers learning OS X.

So, can you help me understand what the below code does? So I have this class:

@interface MiniTabBarButton : NSButton

@property(strong) NSTabViewItem *tabViewItem;

@end

and we create the button:

NSImage* iconImage = [(id MiniTabBarItem)tabViewItem.identifier icon];
[iconImage setTemplate:YES];
newButton.image = iconImage;

So with that in mind, remember I don’t even really know what NSButton provides 
(again, I understand UIButtons really well - and I do have some understanding 
of NSButton custom drawing to some degree as I did write a subclass for the 
checkbox style:
@interface CalendarFilterCheckbox : NSButtonCell

BUT, in this case I’m just trying to get the glow on selected images, so when I 
look at the code below all I see is that we’re getting the bitmap and drawing 
it. I’m not understanding how that gets a glow.

Sorry for being dense, but I do learn quickly. I just am like a blind man at 
first.

 On Nov 4, 2014, at 12:48 PM, Lee Ann Rucker lruc...@vmware.com wrote:
 
 If you want the same blue highlight that NSButton applies to template images, 
 you can get the NSButtonCell to draw it into a graphics context and get an 
 image that way - I answered this when you asked about buttons specifically 
 back in June. (My bug requesting an NSImage method to do that is still open 
 and presumably unloved) Once you've got your buttonCell configured, do this:
 
 
   NSRect bounds = NSZeroRect;
   bounds.size = [template size];
 
   NSBitmapImageRep *bmpImageRep =
  [NSBitmapImageRep imageRepWithSize:bounds.size scale:scale]; // Utility 
 wrapper around imageRepWith32bitBuffer
 
   [NSGraphicsContext saveGraphicsState];
   NSGraphicsContext *bitmapContext =
  [NSGraphicsContext graphicsContextWithBitmapImageRep:bmpImageRep];
   [NSGraphicsContext setCurrentContext:bitmapContext];
 
   [buttonCell drawImage:template withFrame:bounds inView:nil];
 
   [NSGraphicsContext restoreGraphicsState];
   return bmpImageRep;
 
 
 On Nov 4, 2014, at 10:41 AM, Alex Kac a...@webis.net wrote:
 
 I have an NSImage that looks like  in a mini-toolbar - kind of like Xcode. 
 
 Now of course I can just create a hand-drawn selected version, but I like 
 doing things like that in code. So I’d like to have code that takes the 
 NSImage and makes it glow like Xcode here:
 https://urldefense.proofpoint.com/v2/url?u=https-3A__www.dropbox.com_s_by642iw7xosnki7_Screenshot-25202014-2D11-2D04-252011.40.18.png-3Fdl-3D0d=AAIGaQc=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEsr=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNgs=PSrnj94BQRWKM8dFv5gi7Tz3a3NH1_5gmiUvJHsFfP4e=
  
 
 I’ve Googled this and I see a bunch of stuff, that I can’t get working at 
 all. Most articles were for iOS and some repsonders even said “if I was 
 using an NSImage, this would be easy - but for iOS you do…”. 
 
 So… can anyone point me to the right place?
 
 ___
 
 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:
 https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.apple.com_mailman_options_cocoa-2Ddev_lrucker-2540vmware.comd=AAIGaQc=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEsr=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNgs=QsN7f2Wy2w3J4nIWtViq9WfFRo-Fwf46hQqveR8coB0e=
  
 
 This email sent to lruc...@vmware.com
 

Alex Kac - President and Founder
Web Information Solutions, Inc.
To educate a person in mind and not in morals is to educate a menace to 
society.
-- Theodore Roosevelt







___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

auto layout exception: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil

2014-11-05 Thread Chuck Soper
About a week ago, I turned on Auto Layout for xib file that contains a
view. I added constraints and my subviews (some images and a label) were
positioned exactly as I wanted. I thought that auto layout was great.
Today, I discovered that the app crashes on iOS 7.1 using the simulator
for an iPhone 5s. Console output is below. I'm using Xcode 6.1. Everything
works fine on iOS 8.1. Xcode shows no warnings or errors for the
constraints. 

I found two similar questions on Stack Overflow, but they didn't help me.
http://stackoverflow.com/questions/26024906/unable-to-create-description-in
-descriptionforlayoutattribute-layoutitem-coeffi
http://stackoverflow.com/questions/14042016/ios-6-auto-layout-constraints-e
rror-something-is-nil

Does anyone have thoughts how to solve this? If I can't find a solution, I
may need to turn off auto layout and revert to using autoresizing.

Console output:
2014-11-05 11:26:32.602 SSP[20856:60b] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: 'Unable to create
description in descriptionForLayoutAttribute_layoutItem_coefficient.
Something is nil'
*** First throw call stack:
(
0   CoreFoundation  0x00011019c495
__exceptionPreprocess + 165
1   libobjc.A.dylib 0x00010fa6599e
objc_exception_throw + 43
2   CoreFoundation  0x00011019c2ad +[NSException
raise:format:] + 205
3   Foundation  0x00010f432548
descriptionForLayoutAttribute_layoutItem_coefficient + 145
4   Foundation  0x00010f4323bc
-[NSLayoutConstraint equationDescription] + 216
5   Foundation  0x00010f432831
-[NSLayoutConstraint description] + 297
6   CoreFoundation  0x00011015d1b9 -[NSArray
descriptionWithLocale:indent:] + 345
7   Foundation  0x00010f2c414e
_NSDescriptionWithLocaleFunc + 64
8   CoreFoundation  0x000110121244
__CFStringAppendFormatCore + 7252
9   CoreFoundation  0x00011015f913
_CFStringCreateWithFormatAndArgumentsAux + 115
10  CoreFoundation  0x0001101bfa5b _CFLogvEx + 
123
11  Foundation  0x00010f2f4276 NSLogv + 79
12  Foundation  0x00010f2f420a NSLog + 148
13  UIKit   0x00010e86a097
-[UIView(UIConstraintBasedLayout_EngineDelegate)
engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:] + 62
14  Foundation  0x00010f4292ac -[NSISEngine
handleUnsatisfiableRowWithHead:body:usingInfeasibilityHandlingBehavior:mutu
allyExclusiveConstraints:] + 521
15  Foundation  0x00010f42a9b1 -[NSISEngine
tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibil
ityHandlingBehavior:mutuallyExclusiveConstraints:] + 353
16  Foundation  0x00010f2e226b -[NSISEngine
tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyE
xclusiveConstraints:] + 663
17  Foundation  0x00010f433180
-[NSLayoutConstraint
_addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstan
tWasRounded:mutuallyExclusiveConstraints:] + 275
18  Foundation  0x00010f2de1b0
-[NSLayoutConstraint
_addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 204
19  UIKit   0x00010e85d591
-[UIView(UIConstraintBasedLayout)
_layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveCo
nstraints:] + 362
20  UIKit   0x00010e85d738
-[UIView(UIConstraintBasedLayout)
_tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutua
llyExclusiveConstraints:] + 30
21  UIKit   0x00010e85d858
-[UIView(UIConstraintBasedLayout)
_tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 232
22  UIKit   0x00010e85db63
__50-[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke + 153
23  Foundation  0x00010f42b29a -[NSISEngine
withBehaviors:performModifications:] + 119
24  UIKit   0x00010e85dabb
-[UIView(UIConstraintBasedLayout) addConstraints:] + 263
25  UIKit   0x00010e4e5078 -[UIButton
updateConstraints] + 2816
26  UIKit   0x00010e867539
-[UIView(AdditionalLayoutSupport)
_internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] +
223
27  UIKit   0x00010e86768a
-[UIView(AdditionalLayoutSupport)

Re: NSImage glowing

2014-11-05 Thread Wim Lewis

On Nov 5, 2014, at 3:43 PM, Alex Kac a...@webis.net wrote:
 BUT, in this case I’m just trying to get the glow on selected images, so when 
 I look at the code below all I see is that we’re getting the bitmap and 
 drawing it. I’m not understanding how that gets a glow.


It’s applied by NSButtonCell, which knows that if it’s in the selected state 
and its image is marked as a template image (or some set of conditions like 
that), then it should apply the glow when drawing.

I take it you’re trying to get this effect in some place other than inside a 
button? It’s not unreasonable to use an NSCell instance elsewhere— that’s 
essentially what cells are for, to abstract away some of the drawing behavior 
from the control view that uses them.

I think NSButtonCell uses NSSetFocusRingStyle() to provide the actual effect, 
but there may be additional magic in there.


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSImage glowing

2014-11-05 Thread Lee Ann Rucker

On Nov 5, 2014, at 5:53 PM, Wim Lewis w...@omnigroup.com wrote:

 
 On Nov 5, 2014, at 3:43 PM, Alex Kac a...@webis.net wrote:
 BUT, in this case I’m just trying to get the glow on selected images, so 
 when I look at the code below all I see is that we’re getting the bitmap and 
 drawing it. I’m not understanding how that gets a glow.
 
 
 It’s applied by NSButtonCell, which knows that if it’s in the selected state 
 and its image is marked as a template image (or some set of conditions like 
 that), then it should apply the glow when drawing.
 
 I take it you’re trying to get this effect in some place other than inside a 
 button? It’s not unreasonable to use an NSCell instance elsewhere— that’s 
 essentially what cells are for, to abstract away some of the drawing behavior 
 from the control view that uses them.
 
 I think NSButtonCell uses NSSetFocusRingStyle() to provide the actual effect, 
 but there may be additional magic in there.

If it's the blue that toolbar buttons apply to template images, it's not using 
that - I don't know what it is, but they were only fuzzy in the first OS that 
used them, and even then they used something else. There's also an etched 
effect it gets, depending on which OS you're in. I sent Alex a sample app that 
puts everything together.

But yes, for fuzzy blue around an icon, all you have to do is call 
NSSetFocusRingStyle before drawing it. This doesn't change the icon colors, 
though.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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