Date   

Re: Adjusting Font Size to fit View Rectangle

Dave
 

Hi,

Couldn’t find it so wrote my own:

(NSInteger) adjustFontSize:(NSInteger) theFontSize toFitWidth:(NSInteger) theWidth
{
NSInteger myFontSize;
NSFont* myFont;
NSSize myContentSize;

myFontSize = theFontSize;
while (YES)
{
myFont = [NSFont fontWithName:self.font.fontName size:myFontSize];
[self setFont:myFont];

myContentSize = [self.attributedStringValue size];
if (myContentSize.width < theWidth)
break;

myFontSize--;
if (myFontSize <= 0)
break;
}

return myFontSize;
}

This is on an NSTextField subclass and works a treat!

All the Best
Dave

On 20 Sep 2018, at 11:51, Dave <dave@looktowindward.com> wrote:

Hi,

Those two methods alter the frame size, I want to keep the same Frame Size but reduce the Font Size of the Content until it fit into the Displayable Area. I’m 99% sure there is a method to do it but maybe its iOS only?

All the Best
Dave

On 20 Sep 2018, at 02:02, Alex Zavatone via Groups.Io <zav=mac.com@groups.io> wrote:

There are two that I am aware of. sizeToFit and sizeThatFits.
On Sep 19, 2018, at 1:29 PM, Dave <dave@looktowindward.com> wrote:

Hi All,

Is there a Cocoa method I can use that will return the best fitting Font Size for a given String and Font?

I seem to remember using a method that does it but can’t seem to find it any more…..

All the Best
Dave






Re: Adjusting Font Size to fit View Rectangle

Dave
 

Hi,

Those two methods alter the frame size, I want to keep the same Frame Size but reduce the Font Size of the Content until it fit into the Displayable Area. I’m 99% sure there is a method to do it but maybe its iOS only?

All the Best
Dave

On 20 Sep 2018, at 02:02, Alex Zavatone via Groups.Io <zav=mac.com@groups.io> wrote:

There are two that I am aware of. sizeToFit and sizeThatFits.
On Sep 19, 2018, at 1:29 PM, Dave <dave@looktowindward.com> wrote:

Hi All,

Is there a Cocoa method I can use that will return the best fitting Font Size for a given String and Font?

I seem to remember using a method that does it but can’t seem to find it any more…..

All the Best
Dave





Re: Can NSView and NSImageView respond to Mouse Clicks?

Dave
 

Hi,

This is for NSView, I’ve not looked into NSImageView as yet.

I tried adding a Gesture Recognizer which sort of work except the Handler gets calls more than nice when I mouse down.

Basically, I want to detect a Mouse Down on an NSView Subclass and when it occurs display a Pop-Up Menu. Don’t understand why I'm getting multiple calls - see code below.

All the Best
Dave

-(instancetype) initWithCoder:(NSCoder*) theDecoder
{
self = [super initWithCoder:theDecoder];
if (self == nil)
return nil;

NSLog(@"initWithCoder: %@",self.identifier);
[self setupView];

return self;
}


-(void) setupView
{
NSPressGestureRecognizer* myGestureRecognizer;

myGestureRecognizer = [[NSPressGestureRecognizer alloc] initWithTarget:self action:@selector(actionPressGesture:)];
myGestureRecognizer.minimumPressDuration = 0.001;
myGestureRecognizer.buttonMask = 1;
myGestureRecognizer.delaysPrimaryMouseButtonEvents = NO;
[self addGestureRecognizer:myGestureRecognizer];
}

-(void) actionPressGesture:(LTWTestViewCell*) theSender
{
NSLog(@"actionPressGesture: %@",self.identifier);
}

On 20 Sep 2018, at 02:03, Alex Zavatone via Groups.Io <zav=mac.com@groups.io> wrote:

You can add a gesture to it IIRC.
On Sep 19, 2018, at 1:34 PM, Dave <dave@looktowindward.com> wrote:

Hi,

Can an Custom NSView respond to Mouse Clicks via IBActions?

Can the same be done with NSImageView? I’ve added an image view and connected it to an IBAction method define in my View Controller, but when I click the NSImageView nothing happens…..

Any help greatly appreciated.

All the Best
Dave



Updating to Xcode 10

John Brownie
 

After a hiatus of some months, I'm back to programming, and just got Xcode 10 installed. When I go to build, I get all kinds of changes suggested. I make some, but then I get stuck some that I cannot work out. My project is a mixture of Objective-C, Objective-C++, C++, and a little Swift (in a separate target).

When I start to build the first target, clang gives the the warning:
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

OK, so I add a compiler flag as suggested, and I get the following warnings:
error: invalid value 'libc++' in '-std=libc++'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard

Using one of those (c++11), brings me back to the first warning. And then the compiler can't find the standard library headers (e.g. <algorithm>), anyway.

One of the suggested changes was "Update C++ Standard Library", so I reverted to pre-changes and didn't make that change, which got me to the second set of warnings.

Anyone have an idea how to break out of this cycle?

John
--
John Brownie
Mussau-Emira language, New Ireland Province, Papua New Guinea
Kouvola, Finland


Re: Can NSView and NSImageView respond to Mouse Clicks?

Alex Zavatone
 

You can add a gesture to it IIRC.

On Sep 19, 2018, at 1:34 PM, Dave <dave@looktowindward.com> wrote:

Hi,

Can an Custom NSView respond to Mouse Clicks via IBActions?

Can the same be done with NSImageView? I’ve added an image view and connected it to an IBAction method define in my View Controller, but when I click the NSImageView nothing happens…..

Any help greatly appreciated.

All the Best
Dave


Re: Adjusting Font Size to fit View Rectangle

Alex Zavatone
 

There are two that I am aware of. sizeToFit and sizeThatFits.

On Sep 19, 2018, at 1:29 PM, Dave <dave@looktowindward.com> wrote:

Hi All,

Is there a Cocoa method I can use that will return the best fitting Font Size for a given String and Font?

I seem to remember using a method that does it but can’t seem to find it any more…..

All the Best
Dave




Re: Can NSView and NSImageView respond to Mouse Clicks?

Andy Lee
 

On Sep 19, 2018, at 2:34 PM, Dave <dave@looktowindward.com> wrote:
Can the same be done with NSImageView? I’ve added an image view and connected it to an IBAction method define in my View Controller, but when I click the NSImageView nothing happens…..
From the docs:

<https://developer.apple.com/documentation/appkit/nsimageview?language=objc>
Note
An image view calls its action method only when the user drags an image into the image view's bounds, and the image view must be editable to receive dragged images. If you want to display an image and respond to clicks in the image, use an NSButton object instead.
--Andy


Re: Can NSView and NSImageView respond to Mouse Clicks?

Keary Suska
 

NSView doesn’t have action handling—you get that from NSControl. If you need action handling, you might need an NSControl subclass rather than an NSView subclass. That being said, you can call your action method “manually” in an event handler for NSView.

As for NSImageView, It doesn’t look like you can specify action handling in Xcode. Have you tried calling -sendActionOn: on your image view?

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

On Sep 19, 2018, at 12:34 PM, Dave <dave@looktowindward.com> wrote:

Hi,

Can an Custom NSView respond to Mouse Clicks via IBActions?

Can the same be done with NSImageView? I’ve added an image view and connected it to an IBAction method define in my View Controller, but when I click the NSImageView nothing happens…..

Any help greatly appreciated.


Re: Adjusting Font Size to fit View Rectangle

Sandor Szatmari
 

Multiline, or single line?

Sandor

On Sep 19, 2018, at 14:29, Dave <dave@looktowindward.com> wrote:

Hi All,

Is there a Cocoa method I can use that will return the best fitting Font Size for a given String and Font?

I seem to remember using a method that does it but can’t seem to find it any more…..

All the Best
Dave




Can NSView and NSImageView respond to Mouse Clicks?

Dave
 

Hi,

Can an Custom NSView respond to Mouse Clicks via IBActions?

Can the same be done with NSImageView? I’ve added an image view and connected it to an IBAction method define in my View Controller, but when I click the NSImageView nothing happens…..

Any help greatly appreciated.

All the Best
Dave


Adjusting Font Size to fit View Rectangle

Dave
 

Hi All,

Is there a Cocoa method I can use that will return the best fitting Font Size for a given String and Font?

I seem to remember using a method that does it but can’t seem to find it any more…..

All the Best
Dave


Re: Segue

Gerriet M. Denkmann
 

On 19 Sep 2018, at 20:35, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

On Sep 19, 2018, at 05:14:11, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

I have an UITableViewController and the UITableViewCells have a Detail Accessory with an accessory action = Navigation Controller Show Detail

The UITableViewController does prepareForSegue.

The Storyboard Segue is of Kind Show Detail (e.g. Replace) and it Animates.

But: the Detail View slides in from *below* (expect: from right); sliding the Detail View from left to right does *not* get back to the UITableViewController and on top there is no “< Master” button which does the same.
Perhaps you just need to provide a custom transition animation. See this guide:

https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html
The Xcode template Master-Detail App does it without custom transition animation.

It uses: Master : UITableViewController → UINavigationController → Detail : UIViewController

Detail slides in from right, and the user can remove the topmost view controller using the back button in the navigation bar or using a left-edge swipe gesture.


The only way I got it to work:
Master : UITableViewController → Detail : UIViewController
Storyboard Segue Kind = Show (e.g. Push)

Transition Style and Presentation of Master seems to have no effect.

Gerriet.


Re: Segue

Alex Zavatone
 

Change the Kind of the segue.  You’re going to want it set to Show (e.g. Push).

Also check below in the right panel and see which Presentation and which Transition you use.

On Sep 19, 2018, at 5:14 AM, Gerriet M. Denkmann <g@...> wrote:

iOS 11, Xcode 10

I have an UITableViewController and the UITableViewCells have a Detail Accessory with an accessory action = Navigation Controller Show Detail

The UITableViewController does prepareForSegue.

The Storyboard Segue is of Kind Show Detail (e.g. Replace) and it Animates.

But: the Detail View slides in from *below* (expect: from right); sliding the Detail View from left to right does *not* get back to the UITableViewController and on top there is no “< Master” button which does the same.

I tried to copy the Master-Detail App (supplied by Xcode) as closely as possible.
Everything looks the same, but it behaves differently.
What am I doing wrong?

Gerriet.






Re: Segue

Steve Mills
 

On Sep 19, 2018, at 05:14:11, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

I have an UITableViewController and the UITableViewCells have a Detail Accessory with an accessory action = Navigation Controller Show Detail

The UITableViewController does prepareForSegue.

The Storyboard Segue is of Kind Show Detail (e.g. Replace) and it Animates.

But: the Detail View slides in from *below* (expect: from right); sliding the Detail View from left to right does *not* get back to the UITableViewController and on top there is no “< Master” button which does the same.
Perhaps you just need to provide a custom transition animation. See this guide:

https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html

--
Steve Mills
Drummer, Mac geek


Segue

Gerriet M. Denkmann
 

iOS 11, Xcode 10

I have an UITableViewController and the UITableViewCells have a Detail Accessory with an accessory action = Navigation Controller Show Detail

The UITableViewController does prepareForSegue.

The Storyboard Segue is of Kind Show Detail (e.g. Replace) and it Animates.

But: the Detail View slides in from *below* (expect: from right); sliding the Detail View from left to right does *not* get back to the UITableViewController and on top there is no “< Master” button which does the same.

I tried to copy the Master-Detail App (supplied by Xcode) as closely as possible.
Everything looks the same, but it behaves differently.
What am I doing wrong?

Gerriet.


Re: iOS: TableView inside ScrollView

Gerriet M. Denkmann
 

On 19 Sep 2018, at 07:16, Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

On Sep 18, 2018, at 01:47 , Gerriet M. Denkmann <g@mdenkmann.de> wrote:

The problem: if the TableView does *not* have a definite height, then Xcode complains: “The ScrollView needs y-position or height fixed”.
Keep in mind that UITableView is a kind of UIScrollView, which isn’t how NSTableView works. Your intended solution nests a scroll view within a scroll view, which is kind of hard to know how to lay out satisfactorily.

Steve’s suggestion of a table view with 3 sections is a good solution.
Yes. It certainly looks better than my current work-around:

NSLayoutConstraint *heightConstraint = self.tableView.constraints.firstObject;
heightConstraint.constant = nbr of rows in table * row height;

The documentation says: “See the Settings application for examples of grouped tables.”

So I am going to implement this.

Thanks a lot.


Kind regards,

Gerriet.


Re: iOS: TableView inside ScrollView

Quincey Morris
 

On Sep 18, 2018, at 01:47 , Gerriet M. Denkmann <g@...> wrote:

The problem: if the TableView does *not* have a definite height, then Xcode complains: “The ScrollView needs y-position or height fixed”.

Keep in mind that UITableView is a kind of UIScrollView, which isn’t how NSTableView works. Your intended solution nests a scroll view within a scroll view, which is kind of hard to know how to lay out satisfactorily.

Steve’s suggestion of a table view with 3 sections is a good solution.


Re: XPC Question

Sandor Szatmari
 

On Sep 18, 2018, at 12:46, Jens Alfke <jens@...> wrote:



On Sep 18, 2018, at 4:00 AM, Sandor Szatmari <admin.szatmari.net@...> wrote:

Can you do XPC RPC over an IP connection?  Or, in other words… Can you do XPC between two computers?

Jens, thanks for your input.
Not as far as I know.

In general, it’s a bad idea to use this sort of “hidden” RPC across a network. Networking is fundamentally unlike local function calls, and making a network call look exactly like a method call hides those differences and makes it easy to run into problems handling failures, dealing with protocol changes, enforcing security, and more.

Unfortunately Apple doesn’t have any good frameworks for implementing messaging between computers, especially on the listener (“server”) end. The best general purpose protocol right now is probably WebSockets, but there’s still no support for it in Apple’s frameworks, and it’s not easy to implement yourself.

We have several in house apps using DO over the LAN (in a 10.12 environment, in deployment since 10.5 or 10.4 if not earlier) and aside from security concerns for public use it has been great for implementing RPC.  We’ve had these services running for many years and they have been very stable.  As long as you know the demarcation between local and remote, things go smoothly. 

I am looking to implement some new functionality and wanted to make sure there was nothing I was overlooking.  I don’t think I’ll use DO as I’d like to not continue a dependency on outdated technology.  I would prefer to not have to implement my own protocol at a low level.

Any higher level options you can suggest would be appreciated.  The scenario is a launchd daemon running on multiple machines that can be controlled by a console app.  Send commands from the console app to the daemons, read statuses from the daemons.

Thanks!

Sandor


—Jens


Re: XPC Question

Ben Kennedy
 

On 18 Sep 2018, at 9:46 am, Jens Alfke <jens@mooseyard.com> wrote:

Unfortunately Apple doesn’t have any good frameworks for implementing messaging between computers, especially on the listener (“server”) end.
This thread would be incomplete without at least a nostalgic mention of Distributed Objects though!

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DistrObjects/Concepts/AboutDistributedObjects.html

(The revision history page is a sobering testament to its obsoleteness)

b


Re: XPC Question

 



On Sep 18, 2018, at 4:00 AM, Sandor Szatmari <admin.szatmari.net@...> wrote:

Can you do XPC RPC over an IP connection?  Or, in other words… Can you do XPC between two computers?

Not as far as I know.

In general, it’s a bad idea to use this sort of “hidden” RPC across a network. Networking is fundamentally unlike local function calls, and making a network call look exactly like a method call hides those differences and makes it easy to run into problems handling failures, dealing with protocol changes, enforcing security, and more.

Unfortunately Apple doesn’t have any good frameworks for implementing messaging between computers, especially on the listener (“server”) end. The best general purpose protocol right now is probably WebSockets, but there’s still no support for it in Apple’s frameworks, and it’s not easy to implement yourself.

—Jens

701 - 720 of 1422