Wednesday, July 17, 2019

#1 2019-05-26 04:08:06 pm

chrisndeca
Member
From:: Oakland, CA
Registered: 2005-06-28
Posts: 19

Displaying Text in a window

So I have been scouring the Objective-C documentation and Googling all over the place, but I can't seem to figure out how to display text in a window.

Here is the code that sets up and displays the window (this is not my code, it is something I found on a Keyboard Maestro form and did some modifications on).

Applescript:

tell (NSWindow's alloc()'s ¬
           initWithContentRect:{{theWidth, theHeight}, {640, 480}} ¬
               styleMask:NSBorderlessWindowMask ¬
               backing:NSBackingStoreBuffered ¬
               defer:true)
                   
           setOpaque_(yes)
           setAlphaValue_(0.5)
           setBackgroundColor_(NSColor's grayColor())
           setReleasedWhenClosed_(yes)
           setExcludedFromWindowsMenu_(yes)
           orderFrontRegardless()
           delay 5
           |close|()
       end tell

I'd like to use this as an alert, so displaying text in a large size would be great. But at this point I'd be happy to display text of any size in that window just to get me started on the right path.

I can post the entire script if it helps.

Thanks

Offline

 

#2 2019-05-26 05:40:34 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5755

Re: Displaying Text in a window

You need to create an NSTextField and add it to your window's contentView. But if you're using Xcode, you'd be better to do it in its Interface Builder.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)