How to center a text view with Applescript Objective C? - objective-c

I have a simple text view (which is inside a scroll view) and for the life of me I cannot make it center the text inside the text view. There is no choice in the inspector to center the text like there is when you use a normal text field. I have tried stuff like:
tell textView to setTextAlignment_(current application's setTextAlignment UITextAlignmentCenter)
But, obviously that fails. How is this done?

Try use:
tell textView to setAlignment_(current application's NSTextAlignmentCenter)

Related

Is there a way to obtain just the text visible in window in NSView or NSTextView?

I'd like to show information in a second view that's contextualized to what's appearing in the first view. To do that, I'd like to get just the text that's scrolled into view in the NSView. As in the picture I've attached, the whole document is A. The portion that's visible is B. I'm writing this using Objective-C and Swift, so a suggestion in either language would be welcome. Thank you.

Label/Text inside NSProgressIndicator?

It seems that everybody that needs some text for a NSProgressIndicator (i.e. showing the percentage of a download) ends up putting the text above the widget, or next to it.
Cannot you really show any text inside the NSProgressIndicator widget?
An example of what I mean:
In IB, just embed your progress indicator in a custom view, add a label to that view, and center both the progress indicator and the label within the custom view.
You can put a label where ever you want. The progress indicator doesn't have a text property. So yes, you could put a label onto a progress indicator. If that would look good is an other question.

NSTextView Text Alignment

well, I was searching for the code to make the "Left/Center/Right" Alignment for the NSTextView. I observe that in Text Menu, this functionality exists, and it is linked to the first responder calling the "alignCenter" selector. However I could not make it to work.
So I start to read the source code of TextEdit. It seems that Apple implement it and shows in the toolbar. However I was not able to find where it is. (It's not in any .nib file, and there's no selector related to align or centre or left, etc..)
So can anyone tell me: how to implement the function exactly like that in the Text Menu.
OR
Where the heck did Apple put the source code of aligning the text in their TextEdit program?
NSTextView inherits from NSText, which implements the alignCenter:, alignLeft: etc. actions.
You can use use the alignment property on NSTextView and set the alignment you want (.justified, .center, .left, .natural, etc)
let textView = NSTextView()
textView.alignment = .justified
or
textView.alignment = .center

Question about these UIButtons

How can I get a UIButton like the ones at the bottom of this picutre (move and delete)? Specifically, I want an image with a text just like that. http://4.bp.blogspot.com/_QLwms0mVa4w/SQN0MqPIpXI/AAAAAAAAAA8/lEikKn9eP_0/s1600-h/Screenshot+2008-10-25+15:31:21+-0400-1.png
Thanks.
For Jason:
The image sticks right beside the label. Is there anyway from IB I can set it to align to the left, while the label aligns to the right? Here's what it looks like right now:
What you can do is in Interface Builder, the UIButton can be set to a type of "Custom"
After you have done this, you can simply use your own image for the button and different images for each state of the button.
Although with this approach you won't be able to have additional text modified on it like the mail app has with "Delete (1)". However, if you don't need that then this solution will work for you.
Alternatively, if you just want an image stuck onto your existing button then there is an Image property in Interface Builder where you can slap on an image to your button.
If you need more functionality then you would probably have to create your own UIButton by subclassing to handle it.

Assigning a Background image to CGRect Object!

I am new to iphone Programming . I have a rectangle on which i display some data. I want to assign an image to its background. And is it possible that the data would be visible even after the image is assigned . Any idea how i can do it ?
Thanks
You don't say how you are displaying your data, so it isn't possible to respond properly.
But in general, you create simple displays using Interface Builder, and can position a UILabel over a UIImageView, and can set the labels background to be transparent.
If you are drawing using drawRect:, then you probably shouldn't be. And yes, you can draw text over an image doing it this way, too.
CGRect is just a structure representing an abstract rectangle. You do not associate styling information (e.g. color, background image, etc.) to it because this does not make sense.
If you simply want to display an image on a window, drag the PNG image into your project, then you can find your image in Interface Builder, which can be put onto the window.