当前位置: 首页>>代码示例>>C#>>正文


C# NSEvent.characters方法代码示例

本文整理汇总了C#中NSEvent.characters方法的典型用法代码示例。如果您正苦于以下问题:C# NSEvent.characters方法的具体用法?C# NSEvent.characters怎么用?C# NSEvent.characters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSEvent的用法示例。


在下文中一共展示了NSEvent.characters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleKey

        public bool HandleKey(NSTextView view, NSEvent evt)
        {
            bool handled = false;

            try
            {
                if (m_database != null)
                {
                    NSRange range = view.selectedRange();

                    NSString chars = evt.characters();
                    if (range.length == 0 && chars.length() == 1 && chars[0] == '.')
                    {
                        view.insertText(NSString.Create('.'));
                        Unused.Value = DoComplete(this.DoCompleteDot, view, range);
                        handled = true;
                    }
                    else if (range.length == 0 && chars.length() == 1 && chars[0] == '\t')
                    {
                        handled = DoCompleteTab(view, evt, range);
                    }

                    if (!handled)
                    {
                        var annotation = m_boss.Get<IArgsAnnotation>();
                        handled = annotation.HandleKey(view, evt);
                    }
                }
            }
            catch (Exception e)
            {
                Log.WriteLine(TraceLevel.Error, "Errors", "Autocomplete failed:");
                Log.WriteLine(TraceLevel.Error, "Errors", e.ToString());

                NSString title = NSString.Create("Auto-complete failed.");
                NSString message = NSString.Create(e.Message);
                Unused.Value = Functions.NSRunAlertPanel(title, message);
            }

            return handled;
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:41,代码来源:AutoComplete.cs

示例2: keyDown

        public new void keyDown(NSEvent evt)
        {
            NSString chars = evt.characters();

            // TODO: Would be nice to also complete for '.' and ','. This should insert
            // the punctuation and, for '.', start a new completion.
            if (chars.Equals("\t") || chars.Equals("\r") || chars.Equals(" ") || chars.Equals("("))
            {
                DoComplete(false, selectedRow());
            }
            else if (evt.keyCode() == Constants.EnterKey)
            {
                DoComplete(true, selectedRow());
            }
            else if (chars.Equals(Constants.Escape))
            {
                m_text = null;
                window().windowController().Call("hide");
            }
            else if (chars.length() == 1 && (char.IsLetterOrDigit(chars[0]) || chars[0] == '_'))
            {
                m_completed += chars[0];
                int count = DoMatchName();
                if (count > 0)
                {
                    reloadData();
                }
                else if (m_completed.Length == 1)
                {
                    // It's rather confusing to have completed text without any indication
                    // that there is completed text so if the user's completed text is completely
                    // bogus we'll reset it.
                    m_completed = string.Empty;
                }
            }
            else if (chars.Equals(Constants.Delete))
            {
                if (m_completed.Length > 0)
                {
                    m_completed = m_completed.Remove(m_completed.Length - 1);
                    DoMatchName();
                    reloadData();
                }
                else
                    Functions.NSBeep();
            }
            else if (chars.length() == 1 && chars[0] == ' ')
            {
                DoMatchName();		// just select the best match
            }
            else
            {
                Unused.Value = SuperCall(NSTableView.Class, "keyDown:", evt);
            }
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:55,代码来源:CompletionsTable.cs


注:本文中的NSEvent.characters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。