Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-25 Thread Dave
I’ve found the Text Storage like this:

NSTextStorage*  myTextStorage;

myTextStorage = [[self.pLogScrollView documentView] textStorage];

> You can control trucation behavior in an NSTextView by using NSTextStorage, 
> which is a subclass of NSMutableAttributedString. The truncation methods are 
> in NSParagraphStyle).

But when I look in NSTextStore Class Reference I can see nothing relating to 
setting paragraph styles?

There’s a “paragraph” property but it says:

Special Considerations
Unless you are dealing with scriptability, you should not invoke this method 
directly.

I can’t believe its this hard to set wrapping or not and I can’t find real info 
on this from searching either.

Does anyone have some code that does this or something similar?

All the Best
Dave


> On 24 Apr 2016, at 18:36, Bill Cheeseman  wrote:
> 
> 
>> On Apr 24, 2016, at 1:13 PM, Dave  wrote:
>> 
>> I’ve got the Text View Selected in XCode/IB and I can’t find any option for 
>> “Layout” in any of the property tabs? Auto-layout is off at the moment for 
>> this window, it wouldn’t have anything to do with that would it?
> 
> I was describing text fields in my first paragraph, about nib files and 
> storyboards. My second paragraph was about text views, which you have to do 
> programmatically as far as I know.
> 
> -- 
> 
> Bill Cheeseman - wjcheese...@comcast.net
> 

___

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

Code to Stack or Tile Windows

2016-04-25 Thread Dave
Hi All,

I seem to remember there being some sample code available to stack or tile 
windows to a particular screen. Is this still available somewhere or are there 
any built-in Cocoa methods to do this?

I can easily write it myself but if there something around that does the job 
I’d rather use it if possible. Basically I just want to place some Windows 
Tiled to a Particular Screen.

Thanks a lot.

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

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

Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-25 Thread Bill Cheeseman

> On Apr 25, 2016, at 6:48 AM, Dave  wrote:
> 
> I can’t believe its this hard to set wrapping or not and I can’t find real 
> info on this from searching either.


For your purposes, the key point is that NSTextStorage is a subclass of 
NSMutableAttributedString, which is in turn a subclass of NSAttributedString. 
You should be looking at methods like NSMutableAttributedString's 
-setAttributes:range:. Basically, you start by creating a dictionary of 
formatting attributes, then you provide it to -setAttributes:range: with the 
range of characters to which you want those attributes applied. That's why 
they're called "attributed" strings -- they are strings with formatting 
attributes.

Look at the introduction to the NSAttributedString technical reference 
document, the NSAttributedString AppKit Additions reference document, Text 
Attribute Programming Topics, and the Attributed String Programming Guide. The 
"Paragraph Attributes" section of the Text Attribute Programming Topics is 
especially pertinent to your question, including its cross reference to the 
much more detailed Ruler and Paragraph Style Programming Topics.

-- 

Bill Cheeseman - wjcheese...@comcast.net

___

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: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-25 Thread Dave
Hi Bill,

I’m familiar with NSAttributedString and friends. I had thought that there was 
a higher level interface to it as it seems like a common thing to want to do.

Basically my ScrollView is just a scrolling line log similar to XCode’s NSLog 
window. I’m just appending an NSString to the Document View like this:

myTextView = [self documentView];
[[[myTextView textStorage] mutableString] appendString:theString];

Should I convert “theString” to a NSAttributedString and then set the 
attributes of this string, or set the attributes of  [[[myTextView textStorage] 
mutableString] ? The reason I ask is because the TextView can get large and I’m 
not sure if setting the attributes each time would slow things down?

Thanks a lot,
All the Best
Dave



> On 25 Apr 2016, at 12:28, Bill Cheeseman  wrote:
> 
> 
>> On Apr 25, 2016, at 6:48 AM, Dave  wrote:
>> 
>> I can’t believe its this hard to set wrapping or not and I can’t find real 
>> info on this from searching either.
> 
> For your purposes, the key point is that NSTextStorage is a subclass of 
> NSMutableAttributedString, which is in turn a subclass of NSAttributedString. 
> You should be looking at methods like NSMutableAttributedString's 
> -setAttributes:range:. Basically, you start by creating a dictionary of 
> formatting attributes, then you provide it to -setAttributes:range: with the 
> range of characters to which you want those attributes applied. That's why 
> they're called "attributed" strings -- they are strings with formatting 
> attributes.
> 
> Look at the introduction to the NSAttributedString technical reference 
> document, the NSAttributedString AppKit Additions reference document, Text 
> Attribute Programming Topics, and the Attributed String Programming Guide. 
> The "Paragraph Attributes" section of the Text Attribute Programming Topics 
> is especially pertinent to your question, including its cross reference to 
> the much more detailed Ruler and Paragraph Style Programming Topics.
> 
> -- 
> 
> Bill Cheeseman - wjcheese...@comcast.net
> 


___

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: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-25 Thread Dave
I tried the following:

myTextView = [self documentView];
[[[myTextView textStorage] mutableString] appendString:theString];

myRange = NSMakeRange(0,[[[myTextView textStorage] mutableString] length] - 1);
[[myTextView textStorage] addAttribute:NSParagraphStyleAttributeName 
value:[NSNumber numberWithInt:NSLineBreakByTruncatingTail] range:myRange];

But this results in nothing being displayed in the ScrollView/TextView.

I thought of appending an Attributed string to the Text Storage, but I can’t 
find a method that accepts an Attributed String, so not sure how I’m supposed 
to just set it to NOT wrap!

If anyone knows the secret please let me know!

Cheers
Dave



> On 25 Apr 2016, at 16:34, Dave  wrote:
> 
> Hi Bill,
> 
> I’m familiar with NSAttributedString and friends. I had thought that there 
> was a higher level interface to it as it seems like a common thing to want to 
> do.
> 
> Basically my ScrollView is just a scrolling line log similar to XCode’s NSLog 
> window. I’m just appending an NSString to the Document View like this:
> 
> myTextView = [self documentView];
> [[[myTextView textStorage] mutableString] appendString:theString];
> 
> Should I convert “theString” to a NSAttributedString and then set the 
> attributes of this string, or set the attributes of  [[[myTextView 
> textStorage] mutableString] ? The reason I ask is because the TextView can 
> get large and I’m not sure if setting the attributes each time would slow 
> things down?
> 
> Thanks a lot,
> All the Best
> Dave
> 
> 
> 
>> On 25 Apr 2016, at 12:28, Bill Cheeseman  wrote:
>> 
>> 
>>> On Apr 25, 2016, at 6:48 AM, Dave  wrote:
>>> 
>>> I can’t believe its this hard to set wrapping or not and I can’t find real 
>>> info on this from searching either.
>> 
>> For your purposes, the key point is that NSTextStorage is a subclass of 
>> NSMutableAttributedString, which is in turn a subclass of 
>> NSAttributedString. You should be looking at methods like 
>> NSMutableAttributedString's -setAttributes:range:. Basically, you start by 
>> creating a dictionary of formatting attributes, then you provide it to 
>> -setAttributes:range: with the range of characters to which you want those 
>> attributes applied. That's why they're called "attributed" strings -- they 
>> are strings with formatting attributes.
>> 
>> Look at the introduction to the NSAttributedString technical reference 
>> document, the NSAttributedString AppKit Additions reference document, Text 
>> Attribute Programming Topics, and the Attributed String Programming Guide. 
>> The "Paragraph Attributes" section of the Text Attribute Programming Topics 
>> is especially pertinent to your question, including its cross reference to 
>> the much more detailed Ruler and Paragraph Style Programming Topics.
>> 
>> -- 
>> 
>> Bill Cheeseman - wjcheese...@comcast.net
>> 
> 
> 
> ___
> 
> 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/dave%40looktowindward.com
> 
> This email sent to d...@looktowindward.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Xcode Source Compiling Order Issue

2016-04-25 Thread Trygve Inda
My product is a System Preferences Pane. Its principal class is MyPrefPane
and is defined correctly in the Info.plist file under NSPrincipalClass.

The bug I am seeing happens when trying to install a new version over the
top of an older one if (and only if) System Preferences is closed or System
Preferences is open but the older pane has not been clicked on (and is thus
not loaded).

I get an error that my pref pane can't run on an Intel Mac and console
reports:

System Preferences[10232]: -[MyMinorClass initWithBundle:]: unrecognized
selector sent to instance 0x7fc60be96170

System Preferences[10232]: [NSPrefPaneBundle instantiatePrefPaneObject]:
error occurred during instantiation.

It seems like System Preferences is trying to init my pref pane by loading a
minor internal class instead of my MyPrefPane class.

In Xcode Build Phases under compile sources, I noticed that the first two
items are:

MyMinorClass.m
MyPrefPane.m

If I reverse these, and compile MyPrefPane.m first, the bug is eliminated.
Putting any other class before MyPrefPane.m results in System Preferences
making the same attempt to call the first-compiled class with
initWithBundle:

Why does the compile order matter?

I found a similar issue here:

http://stackoverflow.com/questions/31373144/xcode-source-compiling-order-iss
ue

He solved it by rebuilding the project. I have just spent 8 hours rebuilding
this complex project and still get the same results as before (this Xcode
project has existed since Xcode 3)

I am unable to reproduce this on a simple Xcode PrefPane template.

Any ideas?

I am not sure if this is an Xcode issue or something in the OS. For now of
course all I can do is make sure the principal class is compiled first.

Trygve



___

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: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-25 Thread Graham Cox

> On 26 Apr 2016, at 2:08 AM, Dave  wrote:
> 
> If anyone knows the secret please let me know!


Set the associated text container to an extremely wide width. The text won’t 
wrap unless there’s a line break.

—Graham



___

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