protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (_keyCommands.Count == 0) { var selector = new ObjCRuntime.Selector(KeySelector); for (var i = 0; i < 10; i++) { _keyCommands.Add(UIKeyCommand.Create((NSString)i.ToString(), 0, selector)); _keyCommands.Add(UIKeyCommand.Create((NSString)i.ToString(), UIKeyModifierFlags.NumericPad, selector)); } for (var i = 0; i < 26; i++) { var key = (char)('a' + i); _keyCommands.Add(UIKeyCommand.Create((NSString)key.ToString(), 0, selector)); } // Viewable on iPad (>= iOS 9) when holding down ⌘ _keyCommands.Add(UIKeyCommand.Create(new NSString("x"), UIKeyModifierFlags.Command, selector, new NSString("Cut"))); _keyCommands.Add(UIKeyCommand.Create(new NSString("c"), UIKeyModifierFlags.Command, selector, new NSString("Copy"))); _keyCommands.Add(UIKeyCommand.Create(new NSString("v"), UIKeyModifierFlags.Command, selector, new NSString("Paste"))); foreach (var kc in _keyCommands) { AddKeyCommand(kc); } } }
static UIKeyCommand UIKeyCommandFrom(NSString nsInput, HardwareKeyModifierKeys modifier, string descriptiveText) { var flags = UIKeyModifierFlagsFrom(modifier); return(string.IsNullOrWhiteSpace(descriptiveText) ? UIKeyCommand.Create(nsInput, flags, _onKeyPressSelector) : UIKeyCommand.Create(nsInput, flags, _onKeyPressSelector, new NSString(descriptiveText))); }
public CEditorController() { AddKeyCommand(UIKeyCommand.Create(new NSString("]"), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("indent:"), new NSString("Indent".Localize()))); AddKeyCommand(UIKeyCommand.Create(new NSString("["), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("outdent:"), new NSString("Outdent".Localize()))); AddKeyCommand(UIKeyCommand.Create(new NSString("/"), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("toggleComment:"), new NSString("Toggle Comment".Localize()))); AddKeyCommand(UIKeyCommand.Create(new NSString("="), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("increaseFontSize:"), new NSString("Increase Font Size".Localize()))); AddKeyCommand(UIKeyCommand.Create(new NSString("-"), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("decreaseFontSize:"), new NSString("Decrease Font Size".Localize()))); AddKeyCommand(UIKeyCommand.Create(new NSString("0"), UIKeyModifierFlags.Command, new ObjCRuntime.Selector("restoreFontSize:"), new NSString("Restore Font Size".Localize()))); }
public void RegisterHandler(KeyCombination combination, Action action) { if (_actions.ContainsKey(combination)) { _actions[combination].Add(action); } else { var command = UIKeyCommand.Create(combination.KeyCommand, combination.ModifierFlags, new Selector(KeyCommandMethodName)); _activeCommands.Add(command); _controller.AddKeyCommand(command); _actions.Add(combination, new List <Action>() { action }); } }
protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); string key = string.Empty; var selector = new Selector("KeyRecv:"); for (int i = 0; i <= 127; i++) { key = ((char)i).ToString(); UIKeyCommand accelerator1 = UIKeyCommand.Create((NSString)key, 0, selector); AddKeyCommand(accelerator1); UIKeyCommand acceleratorShift = UIKeyCommand.Create((NSString)key, UIKeyModifierFlags.Shift, selector); AddKeyCommand(acceleratorShift); } UIKeyCommand accelerator2 = UIKeyCommand.Create((NSString)"\n", 0, selector); AddKeyCommand(accelerator2); UIKeyCommand accelerator3 = UIKeyCommand.Create((NSString)"\r", 0, selector); AddKeyCommand(accelerator3); }
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); } } }
public void Create() { using (var key = new NSString("a")) { Assert.NotNull(UIKeyCommand.Create(key, UIKeyModifierFlags.Command, new Selector("foo")), "Create"); } }