Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: Xcode ApplescriptObjC display sizes

I have written an ASOC project which when displayed on my 27" iMac fits exactly but when viewed on my MacBook some of the display is lost. Is there a way to automatically correct display size depending on screen size. Any guidance would be gratefully received.

Posted on

Reply

Page content loaded

Nov 14, 2017 5:43 AM in response to Frinton Fogey In response to Frinton Fogey

use framework "AppKit"

use AppleScript version "2.4"

use scripting additions


set e to current application'sNSScreen'smainScreen()'s frame as record

set H to height of e's|size|

set W to width of e's|size|

logH

logW

Nov 14, 2017 5:43 AM

Reply Helpful

Nov 14, 2017 8:46 AM in response to VikingOSX In response to VikingOSX

Many thanks for quick reply but cannot get this to work and not sure where to place the code. When I place it at the beginning (before applicationWillFinishLaunching_(aNotification)) it compiles but has no effect on display. If I add the code within the processing it fails to compile with the error Can’t get |size| of {«class form»:«constant ****usrp», «class want»:property, «class seld»:"frame", from:«class ocid» id «data

Sorry to be dim but as you can tell ApplescriptObjC is not my strong point!

Nov 14, 2017 8:46 AM

Reply Helpful

Nov 14, 2017 1:00 PM in response to Frinton Fogey In response to Frinton Fogey

I would put the code in the applicationDidFinishLaunching handler.


Perhaps the following, to set the window to the current screensize.


set screenFrame to current application'sNSScreen'smainScreen()'s frame

set win to current application'sNSWindow'salloc()'s initWithContentRect:screenFramestyleMask:3 backing:(current application'sNSBackingStoreBuffered) defer:false


tell win

its setDelegate:(me)

its setBackgroundColor:(current application'sNSColor'swhiteColor)

its setCollectionBehavior:(current application'sNSWindowCollectionBehaviorFullScreenPrimary)

its toggleFullScreen: (me)

its setReleasedWhenClosed:true

end tell

Nov 14, 2017 1:00 PM

Reply Helpful

Nov 15, 2017 7:42 AM in response to Frinton Fogey In response to Frinton Fogey

It is demonstrating on your MacBook the ability to get the screen size, and open an application window set to those MacBook screen size dimensions. If you bump your mouse against the top of the Window, the close button will appear.

Nov 15, 2017 7:42 AM

Reply Helpful

Nov 15, 2017 8:25 AM in response to VikingOSX In response to VikingOSX

Found the close button at the top of the blank window but when I close that window it then displays the required window but cropped as before. Looks like I am going to have to have two versions each with their own screen size determined through the Size Inspector. I cannot believe that this a problem unique to me, surely the same project can run on different device screen sizes and detect those screen sizes, thanks for your help anyway.

Nov 15, 2017 8:25 AM

Reply Helpful
User profile for user: Frinton Fogey

Question: Xcode ApplescriptObjC display sizes