AppResult GenerateChildrenForNSView(NSView view, List <AppResult> resultSet) { AppResult firstChild = null, lastChild = null; foreach (var child in view.Subviews) { AppResult node = new NSObjectResult(child) { SourceQuery = ToString() }; resultSet.Add(node); if (firstChild == null) { firstChild = node; lastChild = node; } else { lastChild.NextSibling = node; node.PreviousSibling = lastChild; lastChild = node; } if (child.Subviews != null) { AppResult children = GenerateChildrenForNSView(child, resultSet); node.FirstChild = children; } } if (view is NSSegmentedControl || view.GetType().IsSubclassOf(typeof(NSSegmentedControl))) { var segmentedControl = (NSSegmentedControl)view; LoggingService.LogInfo($"Found 'NSSegmentedControl' with {segmentedControl.SegmentCount} children"); for (int i = 0; i < segmentedControl.SegmentCount; i++) { var node = new NSObjectResult(view, i); resultSet.Add(node); if (firstChild == null) { firstChild = node; lastChild = node; } else { lastChild.NextSibling = node; node.PreviousSibling = lastChild; lastChild = node; } } } return(firstChild); }
public static String ControlInfo(NSView view) { var ctrl = ControlFromView(view); if (ctrl != null) { return(ControlInfo(ctrl)); } if (view != null) { return(view.GetType().Name); } return("null"); }
public bool EnsureTextInputImplemented(NSView view = null) { view = view ?? TextInputControl; // determine whether we need to call InterpretKeyEvents ourselves or if it is already handled by the super class (e.g. NSTextView) // for NSTextField (TextBox, etc), we handle the TextInput event via MacFieldEditor TextInputImplemented = !ObjCExtensions.ClassConformsToProtocol(view.GetSuperclass(), MacViewTextInput.NSTextInputClientProtocol_Handle); // if it already conforms to the protocol, add the insertText:replacementRange method only if (view.ConformsToProtocol(MacViewTextInput.NSTextInputClientProtocol_Handle)) { AddMethod(MacView.selInsertTextReplacementRange, MacView.TriggerTextInput_Delegate, EtoEnvironment.Is64BitProcess ? "v@:@{NSRange=QQ}" : "v@:@{NSRange=II}"); return(false); } // Debug.WriteLine($"Adding TextInputClient to {view.GetType()}, Widget: {Widget.GetType()}"); // add the NSTextInputClient protocol to the class var cls = Class.GetHandle(view.GetType()); ObjCExtensions.ClassAddProtocol(cls, MacViewTextInput.NSTextInputClientProtocol_Handle); // add required methods for the NSTextInputClient protocol AddMethod(MacViewTextInput.HasMarkedText_Selector, MacViewTextInput.HasMarkedText_Delegate, "B@:", view); AddMethod(MacViewTextInput.MarkedRange_Selector, MacViewTextInput.MarkedRange_Delegate, "{NSRange=QQ}@:", view); AddMethod(MacViewTextInput.SelectedRange_Selector, MacViewTextInput.SelectedRange_Delegate, "{NSRange=QQ}@:", view); AddMethod(MacViewTextInput.SetMarkedText_Selector, MacViewTextInput.SetMarkedText_Delegate, "v@:@{NSRange=QQ}{NSRange=QQ}", view); AddMethod(MacViewTextInput.UnmarkText_Selector, MacViewTextInput.UnmarkText_Delegate, "v@:", view); AddMethod(MacViewTextInput.ValidAttributesForMarkedText_Selector, MacViewTextInput.ValidAttributesForMarkedText_Delegate, "@@:", view); AddMethod(MacViewTextInput.AttributedStringForProposedRange_Selector, MacViewTextInput.AttributedStringForProposedRange_Delegate, "@@:{NSRange=QQ}^{NSRange=QQ}", view); AddMethod(MacViewTextInput.CharacterIndexForPoint_Selector, MacViewTextInput.CharacterIndexForPoint_Delegate, "Q@:{CGPoint=gg}", view); AddMethod(MacViewTextInput.FirstRectForCharacterRange_Selector, MacViewTextInput.FirstRectForCharacterRange_Delegate, "{CGRect=gggg}@:{NSRange=QQ}^{NSRange=QQ}", view); AddMethod(MacViewTextInput.DoCommandBySelector_Selector, MacViewTextInput.DoCommandBySelector_Delegate, "v@:#", view); AddMethod(MacView.selInsertTextReplacementRange, MacView.TriggerTextInput_Delegate, "v@:@{NSRange=QQ}", view); return(true); }