Drawing Native OSX Windows with D
Mike McKee via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Nov 29 00:03:16 PST 2015
A few interesting things here. I tried to do these things via the
new Apple language, Swift.
* You can enum windows, but unlike Microsoft Windows, you have no
permissions to hide a window. BTW, hiding a window is a window
object method called orderOut(nil), and they only permit it on
your own windows, not another application's windows. However,
that said, there's a neat AppleScript technique that seems to
work in hiding the entire application, rather than just the
window.
osascript -e "tell application "System Events" to set visible of
process "Installer" to false'
* You can enum Cocoa windows and get x,y,w,h, process ID, window
name, and window number (I guess that's an ID) on each. Here's
the technique in Swift:
import Foundation;
import Cocoa;
let windows = CGWindowListCopyWindowInfo(
CGWindowListOption.OptionOnScreenOnly,
CGWindowID(0))! as NSArray;
for var i = 0; i < windows.count; i++ {
let window = windows[i];
let owner = window["kCGWindowOwnerName"] as! String;
if owner != "Installer" {
continue;
}
// do something with your window object here
}
I don't know how to do this in D, but came up with a workaround.
My pkg installer will run a Bash script which will hide the
Installer window via osascript, show a window that I drew with
Swift that basically tells people to wait because it's
downloading components, runs curl to download the payload from
the server and copy it into the appropriate places (as well as
set up system library stuff as needed), and then hide my custom
Swift window (the progress window), and then uses osascript again
to unhide the installer application.
More information about the Digitalmars-d-learn
mailing list