本文整理汇总了C#中NSEvent.locationInWindow方法的典型用法代码示例。如果您正苦于以下问题:C# NSEvent.locationInWindow方法的具体用法?C# NSEvent.locationInWindow怎么用?C# NSEvent.locationInWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSEvent
的用法示例。
在下文中一共展示了NSEvent.locationInWindow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: menuForEvent
public override NSMenu menuForEvent(NSEvent @event)
{
if (menu == null)
return base.menuForEvent(@event);
// NSLog(@"menuForEvent:");
// Find which row is under the cursor
this.window().makeFirstResponder(this);
NSPoint menuPoint = this.convertPoint(@event.locationInWindow()) fromView(null);
int row = this.rowAtPoint(menuPoint);
if (row > -1)
{
bool currentRowIsSelected = this.selectedRowIndexes().containsIndex(row);
if (!currentRowIsSelected)
this.selectRowIndexes(NSIndexSet.indexSetWithIndex(row)) byExtendingSelection(false);
}
else
{
this.deselectAll(null);
}
if (this.numberOfSelectedRows() <= 0)
{
// No rows are selected, so the table should be displayed with all items disabled
NSMenu tableViewMenu = this.menu().copy();
for (int i = 0; i < tableViewMenu.numberOfItems; i++)
tableViewMenu.itemAtIndex(i).setEnabled(false);
return tableViewMenu;
}
else
return this.menu();
}
示例2: menuForEvent
public new NSMenu menuForEvent(NSEvent evt)
{
// If the item clicked on is not selected then select it.
NSPoint baseLoc = evt.locationInWindow();
NSPoint viewLoc = convertPointFromBase(baseLoc);
int row = rowAtPoint(viewLoc);
if (row >= 0)
{
if (!isRowSelected(row))
{
var indexes = NSIndexSet.indexSetWithIndex((uint) row);
selectRowIndexes_byExtendingSelection(indexes, false);
}
}
NSMenu menu = SuperCall(NSOutlineView.Class, "menuForEvent:", evt).To<NSMenu>();
return menu;
}
示例3: DoMouseEventToIndex
private int DoMouseEventToIndex(NSTextView view, NSEvent evt)
{
NSPoint baseLoc = evt.locationInWindow();
NSPoint viewLoc = view.convertPointFromBase(baseLoc);
return (int) view.characterIndexForInsertionAtPoint(viewLoc);
}
示例4: menuForEvent
// Note that the preferred way to do this (as of 10.5) is to attach a menu to the
// table and bind the menu delegate to a controller. Then the controller can
// define menuNeedsUpdate and use that to adjust the selection or change the
// menu items based on the selection.
public new NSMenu menuForEvent(NSEvent evt)
{
NSMenu menu = NSMenu.Alloc().initWithTitle(NSString.Empty);
menu.autorelease();
// Make the window the key window (handleSccs expects that it
// is either the main or the key window).
window().makeKeyAndOrderFront(this);
// If the item clicked on is not selected then select it.
NSPoint baseLoc = evt.locationInWindow();
NSPoint viewLoc = convertPointFromBase(baseLoc);
int row = rowAtPoint(viewLoc);
if (row >= 0)
{
if (!isRowSelected(row))
{
var indexes = NSIndexSet.indexSetWithIndex((uint) row);
selectRowIndexes_byExtendingSelection(indexes, false);
}
}
// Find the items which are selected.
var paths = new List<string>();
foreach (uint index in selectedRowIndexes())
{
TableItem item = (TableItem) (itemAtRow((int) index));
paths.Add(item.Path);
}
// Build the menu.
foreach (string path in paths)
{
if (System.IO.File.Exists(path))
{
Unused.Value = menu.addItemWithTitle_action_keyEquivalent(
NSString.Create("Open as Binary"), "openBinaries:", NSString.Empty);
break;
}
}
Dictionary<string, string[]> commands = Sccs.GetCommands(paths);
foreach (var entry in commands)
{
if (entry.Value.Length > 0)
{
if (menu.numberOfItems() > 0)
menu.addItem(NSMenuItem.separatorItem());
var cmds = new List<string>(entry.Value);
cmds.Sort();
foreach (string command in cmds)
{
Unused.Value = menu.addItemWithTitle_action_keyEquivalent(
NSString.Create(command), "handleSccs:", NSString.Empty);
}
}
}
return menu;
}
示例5: mouseDown
public new void mouseDown(NSEvent evt)
{
NSPoint originalPoint = convertPoint_fromView(evt.locationInWindow(), null);
if (m_selection.size != NSSize.Zero)
{
setNeedsDisplayInRect(m_selection);
m_selection = NSRect.Empty;
}
do
{
evt = window().nextEventMatchingMask(Enums.NSLeftMouseDraggedMask | Enums.NSLeftMouseUpMask);
autoscroll(evt);
NSPoint currentPoint = convertPoint_fromView(evt.locationInWindow(), null);
NSRect oldSelection = m_selection;
m_selection = DoCreateSelectionRect(originalPoint, currentPoint);
setNeedsDisplayInRect(m_selection.Union(oldSelection));
}
while (evt.type() == Enums.NSLeftMouseDragged);
DoInvariant();
}