internal static NSView FindFirstResponder(this NSView view) { //if (view.IsFirstResponder) if (view.Window.FirstResponder == view) { return(view); } foreach (NSView view1 in view.Subviews) { NSView firstResponder = NSViewExtensions.FindFirstResponder(view1); if (firstResponder != null) { return(firstResponder); } } return((NSView)null); }
protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e) { if (e.NewElement != null) { if (this.Control == null) { var uiSearchBar = new NSSearchField((CGRect)RectangleF.Empty); // TODO: Cancel Button //uiSearchBar.ShowsCancelButton = true; //long num = 0; //uiSearchBar.BarStyle = (UIBarStyle)num; NSSearchField uiview = uiSearchBar; NSButton descendantView = NSViewExtensions.FindDescendantView <NSButton> ((NSView)uiview); // TODO: Colors /* * this.cancelButtonTextColorDefaultNormal = descendantView.TitleColor (UIControlState.Normal); * this.cancelButtonTextColorDefaultHighlighted = descendantView.TitleColor (UIControlState.Highlighted); * this.cancelButtonTextColorDefaultDisabled = descendantView.TitleColor (UIControlState.Disabled); */ this.SetNativeControl(uiview); Control.Changed += Search_Changed; Control.EditingBegan += Search_EditingBegan; Control.EditingEnded += Search_EditingEnded; Control.SearchingStarted += Search_SearchingStarted; Control.Cell.CancelButtonCell.Activated += Search_Canceled; } this.UpdatePlaceholder(); this.UpdateText(); this.UpdateFont(); this.UpdateIsEnabled(); this.UpdateCancelButton(); this.UpdateAlignment(); this.UpdateTextColor(); } this.OnElementChanged(e); }
public static IEnumerable <NSView> Descendants(this NSView self) { if (self.Subviews == null) { return(Enumerable.Empty <NSView> ()); } return(Enumerable.Concat <NSView> ((IEnumerable <NSView>)self.Subviews, Enumerable.SelectMany <NSView, NSView> ((IEnumerable <NSView>)self.Subviews, (Func <NSView, IEnumerable <NSView> >)(s => NSViewExtensions.Descendants(s))))); }