Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9055819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:02:54+00:00 2026-06-16T14:02:54+00:00

Context : I have a normal Document-based Cocoa Mac OS X application which uses

  • 0

Context:

I have a normal Document-based Cocoa Mac OS X application which uses an NSTextView for rich text input. The user may edit the font family, point size and colors of the text in the NSTextView.

Base SDK: 10.7
Deployment Target: 10.6


Question:

I would like to implement zooming of the entire UI programmatically (including the NSTextView) while the user is editing text. Scaling the frame of the NSTextView is no problem. But I don’t know how to scale the editable text inside the view which may contain multiple different point sizes in different sub-sections of the entire run of text.

How can I apply a uniform scale factor to the rich text displayed in an NSTextView?

This should play nicely with “rich text”, such that the user’s font family, color and especially point size (which may be different at different points of the run of text) are preserved, but scaled uniformly/relatively.

Is this possible given my Base SDK and Deployment targets? Is it possible with a newer Base SDK or Deployment target?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:02:55+00:00Added an answer on June 16, 2026 at 2:02 pm

    If the intent is to scale the view (and not actually change the attributes in the string), I would suggest using scaleUnitSquareToSize: method: along with the ScalingScrollView (available with the TextEdit sample code) for the proper scroll bar behavior.

    The core piece from the ScalingScrollView is:

    - (void)setScaleFactor:(CGFloat)newScaleFactor adjustPopup:(BOOL)flag
    {
    CGFloat oldScaleFactor = scaleFactor;
        if (scaleFactor != newScaleFactor)
        {
            NSSize curDocFrameSize, newDocBoundsSize;
            NSView *clipView = [[self documentView] superview];
    
            scaleFactor = newScaleFactor;
    
            // Get the frame.  The frame must stay the same.
            curDocFrameSize = [clipView frame].size;
    
            // The new bounds will be frame divided by scale factor
            newDocBoundsSize.width = curDocFrameSize.width / scaleFactor;
            newDocBoundsSize.height = curDocFrameSize.height / scaleFactor;
        }
        scaleFactor = newScaleFactor;
        [scale_delegate scaleChanged:oldScaleFactor newScale:newScaleFactor]; 
    }
    

    The scale_delegate is your delegate that can adjust your NSTextView object:

    - (void) scaleChanged:(CGFloat)oldScale newScale:(CGFloat)newScale
    {
        NSInteger     percent  = lroundf(newScale * 100);
    
        CGFloat scaler = newScale / oldScale;   
        [textView scaleUnitSquareToSize:NSMakeSize(scaler, scaler)];
    
        NSLayoutManager* lm = [textView layoutManager];
        NSTextContainer* tc = [textView textContainer];
        [lm ensureLayoutForTextContainer:tc];
    }
    

    The scaleUnitSquareToSize: method scales relative to its current state, so you keep track of your scale factor and then convert your absolute scale request (200%) into a relative scale request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Rails application I have an action which creates a XML document using
I have a context loader class which loads an XML file with info on
So I have a normal form with 1 textarea and two hidden inputs, which
I have the standard content editor that uses an iFrame as the text area
I have an HTML document, for example: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> </head>
I have the following php script which works flawlessly in normal circumstances (i.e. visiting
I am trying to write a CSS in which when the user writes text
Context I have this piece of Java Code btn.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent
Context I have a live running redis-server. I want to make a backup. Idea:
Context We have a SharePoint site set up on a Windows Server 2008 VM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.