public CocoaWindow(WindowConfiguration config, WebviewBridge bridge) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (bridge == null) { throw new ArgumentNullException(nameof(bridge)); } Handle = AppKit.Call("NSWindow", "alloc"); canResizeField = config.CanResize; var style = GetWantedStyleMask(); ObjC.SendMessage( Handle, ObjC.RegisterName("initWithContentRect:styleMask:backing:defer:"), new CGRect(0, 0, config.Size.Width, config.Size.Height), new UIntPtr((uint)style), new UIntPtr(2), false); webview = new CocoaWebview(bridge); ObjC.Call(Handle, "setContentView:", webview.Handle); webview.TitleChanged += Webview_TitleChanged; windowDelegate = WindowDelegateDefinition.CreateInstance(this); ObjC.Call(Handle, "setDelegate:", windowDelegate.Handle); }
public CocoaApplication() { Factory = new CocoaUiFactory(); SynchronizationContext = new CocoaSynchronizationContext(); Handle = AppKit.Call("NSApplication", "sharedApplication"); appDelegate = AppDelegateDefinition.CreateInstance(this); ObjC.Call(Handle, "setActivationPolicy:", IntPtr.Zero); ObjC.Call(Handle, "setDelegate:", appDelegate.Handle); }
public CocoaApplication() { Factory = new CocoaUiFactory(); SynchronizationContext = new CocoaSynchronizationContext(); Handle = AppKit.Call("NSApplication", "sharedApplication"); appDelegate = AppDelegateDefinition.CreateInstance(this); ObjC.Call(Handle, "setActivationPolicy:", IntPtr.Zero); ObjC.Call(Handle, "setDelegate:", appDelegate.Handle); ObjC.SetProperty(AppKit.GetClass("NSWindow"), "allowsAutomaticWindowTabbing", false); }
public CocoaWebview(WebviewBridge bridge) { this.bridge = bridge ?? throw new ArgumentNullException(nameof(bridge)); IntPtr configuration = WebKit.Call("WKWebViewConfiguration", "new"); IntPtr manager = ObjC.Call(configuration, "userContentController"); callbackClass = CallbackClassDefinition.CreateInstance(this); schemeHandler = SchemeHandlerDefinition.CreateInstance(this); const string scheme = "spidereye"; customHost = new Uri(UriTools.GetRandomResourceUrl(scheme)); ObjC.Call(configuration, "setURLSchemeHandler:forURLScheme:", schemeHandler.Handle, NSString.Create(scheme)); ObjC.Call(manager, "addScriptMessageHandler:name:", callbackClass.Handle, NSString.Create("external")); IntPtr script = WebKit.Call("WKUserScript", "alloc"); ObjC.Call( script, "initWithSource:injectionTime:forMainFrameOnly:", NSString.Create(Resources.GetInitScript("Mac")), IntPtr.Zero, IntPtr.Zero); ObjC.Call(manager, "addUserScript:", script); Handle = WebKit.Call("WKWebView", "alloc"); ObjC.Call(Handle, "initWithFrame:configuration:", CGRect.Zero, configuration); ObjC.Call(Handle, "setNavigationDelegate:", callbackClass.Handle); IntPtr boolValue = Foundation.Call("NSNumber", "numberWithBool:", false); ObjC.Call(Handle, "setValue:forKey:", boolValue, NSString.Create("drawsBackground")); ObjC.Call(Handle, "addObserver:forKeyPath:options:context:", callbackClass.Handle, NSString.Create("title"), IntPtr.Zero, IntPtr.Zero); preferences = ObjC.Call(configuration, "preferences"); }
public CocoaLabelMenuItem(string label) : this(label, "menuCallback:") { callbackClass = CallbackClassDefinition.CreateInstance(this); SetTarget(callbackClass.Handle); }