public override bool DoCommandBySelector(NSControl control, NSTextView textView, MonoMac.ObjCRuntime.Selector commandSelector)
 {
     if (control != null && "insertNewline:".Equals(commandSelector.Name))
     {
         onEnterPressed(control);
         return true;
     }
     return false;
 }
示例#2
0
            internal string[] TextFieldGetCompletions(NSControl control, NSTextView textView, string[] words, NSRange charRange, ref nint index)
            {
                var prefix = textView.String?.Substring(0, (int)charRange.Location + (int)charRange.Length) ?? String.Empty;

                var completions = new List <string>();

                foreach (string s in owner.auto_complete_custom_source)
                {
                    if (s.StartsWith(prefix, StringComparison.CurrentCultureIgnoreCase))
                    {
                        completions.Add(s.Substring((int)charRange.Location));
                    }
                }

                index = -1;
                return(completions.Distinct().OrderBy(x => x).ToArray());
            }
示例#3
0
        public override bool EnterText(string text)
        {
            NSControl control = ResultObject as NSControl;

            if (control == null)
            {
                return(false);
            }

            control.Window.MakeFirstResponder(control);
            foreach (var c in text)
            {
                RealTypeKey(c);
            }

            return(true);
        }
示例#4
0
        public override bool DoCommandBySelector(NSControl control, NSTextView textView, Selector commandSelector)
        {
            switch (commandSelector.Name)
            {
            case "moveUp:":
                OnKeyArrowUp();
                break;

            case "moveDown:":
                OnKeyArrowDown();
                break;

            default:
                return(false);
            }

            return(false);
        }
        protected void UpdateFont(NSControl control, int sizeDelta = 0)
        {
            var font = TreeView.CustomFont ?? TreeView.Font;

            if (font == null)
            {
                return;
            }

            if (sizeDelta != 0)
            {
                control.Font = NSFont.FromDescription(font.FontDescriptor, font.PointSize + sizeDelta);
            }
            else
            {
                control.Font = font;
            }
        }
            internal virtual bool DoCommandBySelector(NSControl control, NSTextView textView, Selector selector)
            {
                switch (selector.Name)
                {
                case "insertTab:":
                case "insertBacktab:":
                    SendWmKey(VirtualKeys.VK_TAB, IntPtr.Zero);
                    return(true);

                case "insertNewline:":
                    SendWmKey(VirtualKeys.VK_RETURN, IntPtr.Zero);
                    return(true);

                case "cancelOperation:":
                    SendWmKey(VirtualKeys.VK_ESCAPE, IntPtr.Zero);
                    return(true);
                }
                return(false);
            }
示例#7
0
        public static SizeRequest GetSizeRequest(
            this NSControl self,
            double widthConstraint,
            double heightConstraint,
            double minimumWidth  = -1.0,
            double minimumHeight = -1.0)
        {
            if (self == null)
            {
                return(new SizeRequest(
                           new Size(widthConstraint, heightConstraint),
                           new Size(minimumWidth, minimumHeight)));
            }

            CGSize cgSize = self.SizeThatFits((CGSize) new SizeF((float)widthConstraint, (float)heightConstraint));

            Xamarin.Forms.Size request = new Xamarin.Forms.Size(cgSize.Width == (nfloat)float.PositiveInfinity ? double.PositiveInfinity : (double)cgSize.Width, cgSize.Height == (nfloat)float.PositiveInfinity ? double.PositiveInfinity : (double)cgSize.Height);
            Xamarin.Forms.Size minimum = new Xamarin.Forms.Size(minimumWidth < 0.0 ? request.Width : minimumWidth, minimumHeight < 0.0 ? request.Height : minimumHeight);
            return(new SizeRequest(request, minimum));
        }
示例#8
0
        public override bool DoCommandBySelector(NSControl control, NSTextView textView, Selector commandSelector)
        {
            if (ProxyResponder != null)
            {
                switch (commandSelector.Name)
                {
                case "insertTab:":
                    if (ProxyResponder.NextResponder())
                    {
                        return(true);
                    }
                    break;

                case "insertBacktab:":
                    if (ProxyResponder.PreviousResponder())
                    {
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }
示例#9
0
        public override AppResult Text(string text, bool exact)
        {
            if (ResultObject is NSControl)
            {
                NSControl control = (NSControl)ResultObject;
                string    value   = control.StringValue;
                if (CheckForText(value, text, exact))
                {
                    return(this);
                }

                if (ResultObject is NSButton)
                {
                    var nsButton = (NSButton)ResultObject;
                    if (CheckForText(nsButton.Title, text, exact))
                    {
                        return(this);
                    }
                }
            }

            return(null);
        }
示例#10
0
        public void AddControl(NSControl control, string text)
        {
            int minWidth       = string.IsNullOrEmpty(text) ? 0 : 200;
            var labelAlignment = new MDAlignment(new MDLabel(text)
            {
                Alignment = NSTextAlignment.Right
            }, true);

            labels.Add(labelAlignment);

            var controlAlignment = new MDAlignment(control, true)
            {
                MinWidth = minWidth
            };

            controls.Add(controlAlignment);

            Add(new MDBox(LayoutDirection.Horizontal, 2, 0)
            {
                { labelAlignment },
                { controlAlignment },
            });
        }
示例#11
0
        internal static NSView LabelControl(string label, float controlWidth, NSControl control)
        {
            var view = new NSView(new RectangleF(0, 0, controlWidth, 28))
            {
                AutoresizesSubviews = true,
                AutoresizingMask    = NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin,
            };

            var text = new NSTextField(new RectangleF(0, 6, 100, 20))
            {
                StringValue     = label,
                DrawsBackground = false,
                Bordered        = false,
                Editable        = false,
                Selectable      = false
            };

            text.SizeToFit();
            float textWidth  = text.Frame.Width;
            float textHeight = text.Frame.Height;

            control.SizeToFit();
            var   rect          = control.Frame;
            float controlHeight = rect.Height;

            control.Frame = new RectangleF(textWidth + 5, 0, controlWidth, rect.Height);

            rect        = view.Frame;
            rect.Width  = control.Frame.Width + textWidth + 5;
            rect.Height = Math.Max(controlHeight, textHeight);
            view.Frame  = rect;

            view.AddSubview(text);
            view.AddSubview(control);

            return(view);
        }
示例#12
0
        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);
        }
示例#13
0
 private bool KeywordsCommandSelector(NSControl control, NSTextView textView, Selector commandSelector)
 {
     if (textView.RespondsToSelector(commandSelector))
     {
         commandHandling = true;
         textView.PerformSelector(commandSelector, null, -1);
         return true;
     }
     return false;
 }
示例#14
0
 public override string[] GetCompletions(NSControl control, NSTextView text_view,
     string [] a, MonoMac.Foundation.NSRange range, int b)
 {
     return new string [0];
 }
示例#15
0
 public override bool TextShouldBeginEditing(NSControl control, NSText fieldEditor)
 {
     return(!_passwordBox.GetTarget()?.IsReadOnly ?? false);
 }
		internal static NSView LabelControl (string label, float controlWidth, NSControl control)
		{
			var view = new NSView (new RectangleF (0, 0, controlWidth, 28)) {
				AutoresizesSubviews = true,
				AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin,
			};
			
			var text = new NSTextField (new RectangleF (0, 6, 100, 20)) {
				StringValue = label,
				DrawsBackground = false,
				Bordered = false,
				Editable = false,
				Selectable = false
			};
			text.SizeToFit ();
			float textWidth = text.Frame.Width;
			float textHeight = text.Frame.Height;
			
			control.SizeToFit ();
			var rect = control.Frame;
			float controlHeight = rect.Height;
			control.Frame = new RectangleF (textWidth + 5, 0, controlWidth, rect.Height);
			
			rect = view.Frame;
			rect.Width = control.Frame.Width + textWidth + 5;
			rect.Height = Math.Max (controlHeight, textHeight);
			view.Frame = rect;
			
			view.AddSubview (text);
			view.AddSubview (control);
			
			return view;
		}
		// -------------------------------------------------------------------------------
		//	handleCommandSelectors
		//
		//	Handle all command selectors that we can handle here
		// -------------------------------------------------------------------------------		
		private bool handleCommandSelectors(NSControl control, NSTextView textView, Selector commandSelector)
		{
			
			bool result = false;
			
			if (textView.RespondsToSelector (commandSelector)){
				commandHandling = true;
				textView.PerformSelector (commandSelector,null,-1);
				//commandHandling = false;
				result = true;
			}
			
			return result;
			
		}
		// -------------------------------------------------------------------------------
		//	control:textView:completions:forPartialWordRange:indexOfSelectedItem:
		//
		//	Use this method to override NSFieldEditor's default matches (which is a much bigger
		//	list of keywords).  By not implementing this method, you will then get back
		//	NSSearchField's default feature.
		// -------------------------------------------------------------------------------		
		//public string[] FilterCompletions (NSControl control, NSTextView textView, string [] words, NSRange charRange, int index)
		string[] handleFilterCompletions (NSControl control, NSTextView textView, string[] words, NSRange charRange, int index) 
		{
			
			var partialString = textView.Value;
			List<string> matches = new List<string> ();

			if (partialString.Length > 0) {
				// find any match in our keyword array against what was typed -
				matches = (from c in builtInKeywords
					where c.StartsWith (partialString, StringComparison.OrdinalIgnoreCase)
					orderby c select c).ToList ();
			}

			return matches.ToArray();

		}
        public NSArray ControlTextViewCompletionsForPartialWordRangeIndexOfSelectedItem(NSControl control, NSTextView textView, NSArray words, NSRange charRange, ref int index)
        {
            NSMutableArray matches;
            NSString partialString;
            NSArray keywords;
            int i;
            uint count;
            NSString str;

            partialString = textView.String.SubstringWithRange(charRange);
            keywords = this.AllKeywords();
            count = keywords.Count;
            matches = new NSMutableArray();

            // find any match in our keyword array against what was typed
            for (i = 0; i < count; i++)
            {
                str = keywords[i].CastTo<NSString>();
                if (str.RangeOfStringOptionsRange(partialString, NSStringCompareOptions.NSAnchoredSearch | NSStringCompareOptions.NSCaseInsensitiveSearch, NSRange.NSMakeRange(0, str.Length)).location != NSUInteger.NSNotFound)
                {
                    matches.AddObject(str);
                }
            }
            matches.SortUsingSelector(ObjectiveCRuntime.Selector("compare:"));

            return matches;
        }
示例#20
0
 private string[] KeywordsGetCompletions(NSControl control, NSTextView textView, string[] words, NSRange charRange, int index)
 {
     return keywordSet.GetMatches(textView.Value);
 }
 public bool ControlTextViewDoCommandBySelector(NSControl control, NSTextView textView, IntPtr commandSelector)
 {
     if (textView.RespondsToSelector(commandSelector))
     {
         this.commandHandling = true;
         textView.PerformSelectorWithObject(commandSelector, null);
         this.commandHandling = false;
     }
     return true;
 }
示例#22
0
 public override string [] GetCompletions(NSControl control, NSTextView text_view,
                                          string [] a, MonoMac.Foundation.NSRange range, int b)
 {
     return(new string [0]);
 }
 internal virtual bool TextFieldShouldBeginEditing(NSControl control, NSText fieldEditor)
 {
     return(!owner.ReadOnly && owner.Enabled);
 }
示例#24
0
            public override bool DoCommandBySelector(NSControl control, NSTextView textView, MonoMac.ObjCRuntime.Selector commandSelector)
            {
                switch (commandSelector.Name)
                {
                    case "moveDown:":
                        controller.MoveSearchResult(false);
                        return true;

                    case "moveUp:":
                        controller.MoveSearchResult(true);
                        return true;

                    case "insertNewline:":
                        controller.ActivateSearchResult();
                        return true;
                }

                return false;
            }