本文整理汇总了C#中NSEvent.keyCode方法的典型用法代码示例。如果您正苦于以下问题:C# NSEvent.keyCode方法的具体用法?C# NSEvent.keyCode怎么用?C# NSEvent.keyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSEvent
的用法示例。
在下文中一共展示了NSEvent.keyCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: keyDown
public new void keyDown(NSEvent evt)
{
if (evt.keyCode() == 36)
doubleClicked(m_table);
else
Unused.Value = SuperCall(NSWindowController.Class, "keyDown:", evt);
}
示例2: keyDown
public new void keyDown(NSEvent evt)
{
bool handled = false;
ushort key = evt.keyCode();
if (key == Constants.ReturnKey || key == Constants.EnterKey)
{
if (m_table.numberOfRows() > 0)
{
doubleClicked(this);
handled = true;
}
}
if (!handled)
Unused.Value = SuperCall(NSWindowController.Class, "keyDown:", evt);
}
示例3: keyDown
public new void keyDown(NSEvent evt)
{
do
{
TextController controller = (TextController) window().windowController();
if (controller.Language != null && controller.Language.Name == "CsLanguage")
{
// Handle auto-complete initiated with '.' or enter.
if (m_autoComplete.HandleKey(this, evt))
break;
}
if (DoTabKey(evt))
break;
if (DoArrowKeys(evt))
break;
if (DoDeleteKey(evt))
break;
// Special case for deleting the new line at the start of a blank line
// (users don't normally want the whitespace to be appended to the
// previous line).
NSRange range = selectedRange();
if (range.location > 0 && range.length == 0)
{
if (evt.keyCode() == Constants.DeleteKey && string_().characterAtIndex((uint) range.location - 1) == '\n')
{
int count = DoGetBlankCount(string_(), range.location);
if (count > 0)
{
setSelectedRange(new NSRange(range.location - 1, count + 1));
delete(this);
break;
}
}
}
// Default key processing.
Unused.Value = SuperCall(NSTextView.Class, "keyDown:", evt);
// For up and down arrow in the whitespace at the start of a line
// we want to set the insertion point to the start of the line (this
// makes it much nicer to do stuff like manually comment out lines).
range = selectedRange();
if (range.length == 0)
{
if (evt.keyCode() == Constants.UpArrowKey || evt.keyCode() == Constants.DownArrowKey)
{
NSString text = string_();
int start = DoGetLineStartFromSpaceOrTab(text, range.location);
if (start >= 0)
{
setSelectedRange(new NSRange(start, 0));
}
}
}
}
while (false);
}
示例4: DoDeleteKey
private bool DoDeleteKey(NSEvent evt)
{
if (evt.keyCode() == Constants.DeleteKey)
{
var range = selectedRange();
if ((evt.modifierFlags() & Enums.NSShiftKeyMask) == Enums.NSShiftKeyMask)
{
if (range.length == 0)
{
// Shift-delete deletes the current line
DoDeleteLine(range.location);
return true;
}
}
else if (range.length == 0)
{
TextController controller = (TextController) window().windowController();
if (controller.Language != null && !controller.UsesTabs && !NSObject.IsNullOrNil(controller.SpacesText))
{
// If we're inserting N spaces for tabs then delete should delete N spaces at a time.
int count = DoGetSpaceCount(string_(), range.location - 1);
int length = (int) controller.SpacesText.length();
if (count >= length)
{
setSelectedRange(new NSRange(range.location - length, length));
delete(this);
return true;
}
}
}
}
return false;
}
示例5: DoArrowKeys
private bool DoArrowKeys(NSEvent evt)
{
bool command = (evt.modifierFlags() & Enums.NSCommandKeyMask) == Enums.NSCommandKeyMask;
bool option = (evt.modifierFlags() & Enums.NSAlternateKeyMask) == Enums.NSAlternateKeyMask;
bool shift = (evt.modifierFlags() & Enums.NSShiftKeyMask) == Enums.NSShiftKeyMask;
if (evt.keyCode() == Constants.LeftArrowKey)
{
if (command && option)
{
// Cycle down through document windows.
DoActivateLowerWindow();
return true;
}
else if (option && shift)
{
// Extend the selection to the left using the previous word (for some reason Cocoa
// does not call selectionRangeForProposedRange_granularity for this).
if (DoExtendSelectionLeft())
return true;
}
else if (option)
{
// Move the insertion point to the start of the previous word.
if (DoMoveSelectionLeft())
return true;
}
}
else if (evt.keyCode() == Constants.RightArrowKey)
{
if (command && option)
{
// Cycle up through document windows.
DoActivateHigherWindow();
return true;
}
else if (option && shift)
{
// Extend the selection to the right of the next word.
if (DoExtendSelectionRight())
return true;
}
else if (option)
{
// Move the insertion point after the end of the next word.
if (DoMoveSelectionRight())
return true;
}
}
else if (evt.keyCode() == Constants.UpArrowKey)
{
if (command && option)
{
// Toggle between *.cpp/*.c/*.m and *.hpp/*.h files.
DoToggleHeader();
return true;
}
}
return false;
}
示例6: DoTabKey
private bool DoTabKey(NSEvent evt)
{
if (evt.keyCode() == Constants.TabKey)
{
TextController controller = (TextController) window().windowController();
if ((evt.modifierFlags() & Enums.NSAlternateKeyMask) != 0)
{
if ((evt.modifierFlags() & Enums.NSShiftKeyMask) == 0)
{
// Option-tab selects the prev identifier.
if (DoSelectNextIdentifier(controller))
return true;
}
else
{
// Option-shift-tab selects the prev identifier.
if (DoSelectPreviousIdentifier(controller))
return true;
}
}
else if ((evt.modifierFlags() & Enums.NSCommandKeyMask) != 0)
{
}
else if ((evt.modifierFlags() & Enums.NSControlKeyMask) != 0)
{
}
else if ((evt.modifierFlags() & Enums.NSShiftKeyMask) != 0)
{
// Shift-tab with at least one line selected unindents lines
var selRange = selectedRange();
if (DoSelectionCrossesLines(selRange))
{
controller.shiftLeft(this);
return true;
}
}
else
{
var selRange = selectedRange();
if (selRange.location > 0 && selRange.length > 1)
{
// Tab with at least one line selected indents lines
if (DoSelectionCrossesLines(selRange))
{
controller.shiftRight(this);
return true;
}
}
else if (selRange.location > 0 && selRange.length == 0)
{
// Tab with no selection at the end of a blank line indents like the previous line.
if (DoMatchPriorLineTabs(selRange.location))
return true;
}
if (controller.Language != null && !controller.UsesTabs)
{
if (!NSObject.IsNullOrNil(controller.SpacesText))
{
this.insertText(controller.SpacesText);
return true;
}
}
}
}
return false;
}
示例7: 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);
}
}