public void JPushSetAlias(string aliasName) { ObjCRuntime.Selector sel = new ObjCRuntime.Selector("tagsAliasCallback"); NSObject obj = new NSObject(); JPUSHService.SetAlias(aliasName, sel, obj); }
public void FocusSearchBar() { var entry = searchEntry; if (!IsSearchEntryInOverflow) { entry.SelectText(entry); } else { // NSSearchField -> NSToolbarItemViewer -> _NSToolbarClipView -> NSToolbarView -> NSToolbarClippedItemsIndicator var clipItem = (NSButton)searchEntry.Superview.Superview.Superview.Subviews [1]; var sel = new ObjCRuntime.Selector("_computeMenuForClippedItemsIfNeeded"); if (!clipItem.RespondsToSelector(sel)) { throw new Exception("Cocoa selector changed for clipped items menu."); } clipItem.PerformSelector(sel); var menu = clipItem.Menu; var searchItem = menu.ItemAt(0); var searchView = (SearchBar)searchItem.View; AttachToolbarEvents(searchView); menu.PopUpMenu(menu.ItemAt(0), new CGPoint(0, -5), clipItem); searchView.SelectText(searchView); } }
public override bool DoCommandBySelector(NSTextView textView, ObjCRuntime.Selector commandSelector) { // if (commandSelector.Name == "insertTab:") { // textView.InsertText (new NSString (" ")); // return true; // } return(false); }
public AlertButtonWrapper(NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert) { this.nsbutton = nsbutton; this.message = message; this.alertButton = alertButton; this.alert = alert; oldAction = nsbutton.Action; }
public override void PerformAction(UITableView tableView, ObjCRuntime.Selector action, NSIndexPath indexPath, NSObject sender) { if (action.Name.Equals("copy:")) { var text = tableView.CellAt(indexPath).TextLabel.Text; UIPasteboard.General.SetData(NSData.FromString(text), "public.plain-text"); } }
protected override void TerminateWithSuccess() { Console.WriteLine("Exiting test run with success"); var s = new ObjCRuntime.Selector("terminateWithSuccess"); UIApplication.SharedApplication.PerformSelector(s, UIApplication.SharedApplication, 0); }
public override bool RespondsToSelector(ObjCRuntime.Selector sel) { if (TabViewController != null && TabViewController.RespondsToSelector(sel)) { return(true); } return(base.RespondsToSelector(sel)); }
public override bool RespondsToSelector(ObjCRuntime.Selector sel) { if (sel.Name == "copy:") { return(logTableView.SelectedRowCount > 0); } return(base.RespondsToSelector(sel)); }
// Remove copy-paste actions public override bool CanPerform(ObjCRuntime.Selector action, NSObject withSender) { if (action == new ObjCRuntime.Selector("copy:") || action == new ObjCRuntime.Selector("selectAll:") || action == new ObjCRuntime.Selector("paste:")) { return(false); } else { return(base.CanPerform(action, withSender)); } }
public override bool RespondsToSelector(ObjCRuntime.Selector sel) { var viewController = TabView?.Selected?.ViewController; if (viewController != null && viewController.RespondsToSelector(sel)) { return(true); } return(base.RespondsToSelector(sel)); }
private static void TerminateWithSuccess() { #if __IOS__ var selector = new ObjCRuntime.Selector("terminateWithSuccess"); UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0); #elif __DROID__ System.Environment.Exit(0); #elif WINDOWS_UWP Windows.UI.Xaml.Application.Current.Exit(); #endif }
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions) { Forms.Init(); var nunit = new App(); nunit.AddTestAssembly(typeof(TestHelpers).Assembly); var options = new TestOptions { LogToOutput = true }; var arguments = NSProcessInfo.ProcessInfo.Arguments .Select(a => a.Replace("-app-arg=", string.Empty)) .ToArray(); if (arguments.Any("--headless".Equals)) { options.AutoRun = true; options.CreateXmlResultFile = true; var hasResultsPath = false; for (var i = 0; i < arguments.Length; i++) { if (arguments[i] == "--resultpath") { options.ResultFilePath = arguments[i + 1]; hasResultsPath = true; break; } } if (!hasResultsPath) { throw new Exception("You must provide path to store test results with --resultpath path/to/results.xml"); } options.OnCompletedCallback = () => { TestHelpers.TransformTestResults(options.ResultFilePath); var selector = new ObjCRuntime.Selector("terminateWithSuccess"); UIApplication.SharedApplication.PerformSelector(selector, UIApplication.SharedApplication, 0); return(Task.CompletedTask); }; } nunit.Options = options; LoadApplication(nunit); return(base.FinishedLaunching(uiApplication, launchOptions)); }
public int RunModalSheet(NSWindow parent) { var sel = new ObjCRuntime.Selector("sheetSel"); NSApplication.SharedApplication.BeginSheet(this, parent, this, sel, IntPtr.Zero); DidResignKey += StopSharedAppModal; try { sheet = true; return(SaveIfOk((int)NSApplication.SharedApplication.RunModalForWindow(this))); } finally { sheet = false; DidResignKey -= StopSharedAppModal; } }
bool CommandBySelector(NSControl control, NSTextField field, ObjCRuntime.Selector sel) { switch (sel.Name) { case "insertTab:": // down arrow CommandRaised?.Invoke(this, SearchTextFieldCommand.InsertTab); return(true); case "insertBacktab:": // up arrow CommandRaised?.Invoke(this, SearchTextFieldCommand.InsertBacktab); return(true); } return(false); }
public static bool IsSelectorExcludedFromWebScript(ObjCRuntime.Selector aSelector) { // For security, you must explicitly allow a selector to be called from JavaScript. if (aSelector.Name == "showMessage:") { return(false); // i.e. showMessage: is NOT _excluded_ from scripting, so it can be called. } if (aSelector.Name == "alert:") { return(false); } return(true); // disallow everything else }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental"); global::Xamarin.Forms.Forms.Init(); //force to app to run RTL layout ObjCRuntime.Selector selector = new ObjCRuntime.Selector("setSemanticContentAttribute:"); AppDelegate.IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, UISemanticContentAttribute.ForceRightToLeft); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public TabButton(IHostResourceProvider hostResource, string imageName = null) { if (hostResource == null) { throw new ArgumentNullException(nameof(hostResource)); } Bordered = false; Action = new ObjCRuntime.Selector(ClickedName); var clicked = new NSClickGestureRecognizer(OnClicked); AddGestureRecognizer(clicked); this.hostResource = hostResource; this.imageName = imageName; AppearanceChanged(); }
private void Terminate() { switch (Device.RuntimePlatform) { case Device.iOS: { #if __IOS__ var selector = new ObjCRuntime.Selector("terminateWithSuccess"); UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0); #endif /* * // We'll just use reflection here, rather than having to start doing multi-targeting just for this one platform specific thing * // Reflection code equivalent to: * // var selector = new ObjCRuntime.Selector("terminateWithSuccess"); * // UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0); * var selectorType = Type.GetType("ObjCRuntime.Selector, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"); * var cnst = selectorType.GetConstructor(new Type[] { typeof(string) }); * var selector = cnst.Invoke(new object[] { "terminateWithSuccess" }); * var UIAppType = Type.GetType("UIKit.UIApplication, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"); * var prop = UIAppType.GetProperty("SharedApplication"); * var app = prop.GetValue(null); * var nsObjectType = Type.GetType("Foundation.NSObject, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"); * var psMethod = UIAppType.GetMethod("PerformSelector", new Type[] { selector.GetType(), nsObjectType, typeof(double) }); * psMethod.Invoke(app, new object[] { selector, app, 0d }); */ } break; case Device.Android: #if __ANDROID__ Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); #endif break; default: Environment.Exit(0); break; } }
protected override void OnElementChanged(VisualElementChangedEventArgs args) { base.OnElementChanged(args); if (!_keyCommands.Any()) { var selector = new ObjCRuntime.Selector(_keySelector); // Add support for special commands (viewable on iPad (>= iOS 9) when holding down ⌘) _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.CopyCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.Copy))); _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.PasteCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.Paste))); _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.RootCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.RootOperator))); // Add support for enter and equals key _keyCommands.Add(UIKeyCommand.Create((NSString)_enterKey, 0, selector)); _keyCommands.Add(UIKeyCommand.Create((NSString)HardwareInput.ResultOperator, 0, selector)); // Add support for backspace key _keyCommands.Add(UIKeyCommand.Create((NSString)_backspaceKey, 0, selector)); // Add support for numbers for (var i = 0; i < 10; i++) { _keyCommands.Add(UIKeyCommand.Create((NSString)i.ToString(), 0, selector)); } // Add support for parentheses, decimal separators and operators foreach (var symbol in HardwareInput.ParenthesesDecimalSeparatorsAndOperators) { _keyCommands.Add(UIKeyCommand.Create((NSString)symbol, 0, selector)); } foreach (var kc in _keyCommands) { AddKeyCommand(kc); } } }
void handleControl(UIView view, UIControlEvent controlEvent) { var control = view as UIControl; if (control != null) { var targets = control.AllTargets; foreach (var target in targets) { var actions = control.GetActions(target, controlEvent); if ((actions != null) ) { foreach (var action in actions) { var selectorString = action; var selector = new ObjCRuntime.Selector(selectorString); control.SendAction(selector, target, null); } } } } }
public override bool RespondsToSelector(ObjCRuntime.Selector sel) { log("RespondsToSelector -> " + sel.Name); return(base.RespondsToSelector(sel)); // Internal - nothing to do here. }
public static void OnLayoutDirectionChange() { ObjCRuntime.Selector selector = new ObjCRuntime.Selector("setSemanticContentAttribute:"); IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, GetSemanticContentAttribute()); }
public override bool RespondsToSelector(ObjCRuntime.Selector sel) { return(base.RespondsToSelector(sel)); }
protected override void TerminateWithSuccess() { var s = new ObjCRuntime.Selector("terminateWithSuccess"); UIApplication.SharedApplication.PerformSelector(s, UIApplication.SharedApplication, 0); }
public virtual override bool RespondsToSelector(ObjCRuntime.Selector sel) { throw new NotImplementedException(); }
public virtual override Foundation.NSObject PerformSelector(ObjCRuntime.Selector aSelector, Foundation.NSObject object1, Foundation.NSObject object2) { throw new NotImplementedException(); }
public override void DoesNotRecognizeSelector(ObjCRuntime.Selector sel) { log("DoesNotRecognizeSelector -> " + sel.Name); // Internal - nothing to do here. }
public override void PerformSelector(ObjCRuntime.Selector sel, NSObject obj, double delay) { log("PerformSelector"); // Internal - nothing to do here. }
public override bool DoCommandBySelector(NSControl control, NSTextView textView, ObjCRuntime.Selector commandSelector) { if (commandSelector.Name.Equals("cancelOperation:")) //Esc { PressedEscKey?.Invoke(control, EventArgs.Empty); } else if (commandSelector.Name.Equals("insertNewline:")) //Enter { PressedEnterKey?.Invoke(control, EventArgs.Empty); } else if (commandSelector.Name.Equals("insertLineBreak:")) //Ctrl + Enter { return(true); } else if (commandSelector.Name.Equals("insertNewlineIgnoringFieldEditor:")) //Alt + Enter { return(true); } return(false); }
public int RunModalSheet (NSWindow parent) { var sel = new ObjCRuntime.Selector ("sheetSel"); NSApplication.SharedApplication.BeginSheet (this, parent, this, sel, IntPtr.Zero); DidResignKey += StopSharedAppModal; try { sheet = true; return SaveIfOk ((int)NSApplication.SharedApplication.RunModalForWindow (this)); } finally { sheet = false; DidResignKey -= StopSharedAppModal; } }
public void FocusSearchBar () { var entry = searchEntry; if (!IsSearchEntryInOverflow) entry.SelectText (entry); else { // NSSearchField -> NSToolbarItemViewer -> _NSToolbarClipView -> NSToolbarView -> NSToolbarClippedItemsIndicator var clipItem = (NSButton)searchEntry.Superview.Superview.Superview.Subviews [1]; var sel = new ObjCRuntime.Selector ("_computeMenuForClippedItemsIfNeeded"); if (!clipItem.RespondsToSelector (sel)) throw new Exception ("Cocoa selector changed for clipped items menu."); clipItem.PerformSelector (sel); var menu = clipItem.Menu; var searchItem = menu.ItemAt (0); var searchView = (SearchBar)searchItem.View; AttachToolbarEvents (searchView); menu.PopUpMenu (menu.ItemAt (0), new CGPoint (0, -5), clipItem); searchView.SelectText (searchView); } }
public override void InvokeOnMainThread(ObjCRuntime.Selector sel, Foundation.NSObject obj) { }
public AlertButtonWrapper (NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert) { this.nsbutton = nsbutton; this.message = message; this.alertButton = alertButton; this.alert = alert; oldAction = nsbutton.Action; }