-
Notifications
You must be signed in to change notification settings - Fork 11
Loading and calling AppKit #44
Copy link
Copy link
Closed
Description
I took a code snippet calling AppKit from an old version of ObjectiveC.jl and adapted it to the current one. Specifically, I needed [NSApp setActivationPolicy].
Not sure if it looks reasonable already or should be written better? I'm not really familiar with ObjectiveC itself...
Here's the code in question, seems very verbose:
using ObjectiveC: id, Object, NSString, NSObject, @objc, @objcwrapper
@objcwrapper NSApplication <: NSObject
function show_gl_icon_in_dock(show::Bool)
path = "/System/Library/Frameworks/AppKit.framework"
path = NSString(path)
bundle = @objc [NSBundle bundleWithPath:path::id{NSString}]::id{Object}
loaded = @objc [bundle::id{Object} load]::id{Object}
NSApp = Base.bitcast(id{Object}, cglobal(:NSApp, Ptr{Cvoid}) |> unsafe_load)
@objc [NSApplication sharedApplication]::id{Object}
NSApplicationActivationPolicyRegular = 0
NSApplicationActivationPolicyAccessory = 1
val = show ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory
@objc [NSApp::id{Object} setActivationPolicy:val::Int]::id{Object}
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels