本文整理汇总了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;
}
示例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);
}
}