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


C# NSEvent类代码示例

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


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

示例1: MouseDown

        public override void MouseDown(NSEvent theEvent)
        {
            NSPoint locationInSelf = this.ConvertPointFromView (theEvent.LocationInWindow, null);
            NSRect dragThumbFrame = this.dragThumbView.Frame;

            if (dragThumbFrame.PointInRect (locationInSelf)) {
                this.dragOffsetIntoGrowBox = new NSSize (locationInSelf.x - dragThumbFrame.origin.x, locationInSelf.y - dragThumbFrame.origin.y);
                NSDictionary metrics = NSDictionary.DictionaryWithObjectsAndKeys (
                NSNumber.NumberWithFloat (dragThumbFrame.MinX), (NSString)"initialThumbX",
                NSNumber.NumberWithFloat (dragThumbFrame.MinY), (NSString)"initialThumbY",
                null);
                NSDictionary views = NSDictionary.DictionaryWithObjectForKey (this.dragThumbView, (NSString)"dragThumbView");

                this.horizontalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("H:|-(initialThumbX)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();
                this.verticalDragConstraint = NSLayoutConstraint.ConstraintsWithVisualFormatOptionsMetricsViews ("V:|-(initialThumbY)-[dragThumbView]", 0, metrics, views).LastObject.Retain<NSLayoutConstraint> ();

                // try lowering the priority to NSLayoutPriorityDragThatCannotResizeWindow to see the difference
                this.horizontalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;
                this.verticalDragConstraint.Priority = NSLayoutPriority.NSLayoutPriorityDragThatCanResizeWindow;

                this.AddConstraint (this.horizontalDragConstraint);
                this.AddConstraint (this.verticalDragConstraint);

                // just for fun.  Try it out!
                this.Window.VisualizeConstraints (NSArray.ArrayWithObjects (this.horizontalDragConstraint, this.verticalDragConstraint, null));
            }
        }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:27,代码来源:ResizableView.cs

示例2: HandleKeyAction

		void HandleKeyAction (NSEvent theEvent, bool isUp)
		{
			ulong code = DecodeFromUnicode (theEvent.Characters);
			NSKey keyPressed;

			if (code == 32)
				keyPressed = NSKey.Space;
			else if (code == 114)
				keyPressed = NSKey.R;
			else
				keyPressed = (NSKey)DecodeFromUnicode (theEvent.Characters);

			switch (keyPressed) {
			case NSKey.RightArrow:
				UpdateKey (RightKey, isUp);
				break;
			case NSKey.LeftArrow:
				UpdateKey (LeftKey, isUp);
				break;
			case NSKey.R:
				UpdateKey (RunKey, isUp);
				break;
			case NSKey.Space:
				UpdateKey (JumpKey, isUp);
				break;
			default:
				break;
			}
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:29,代码来源:SharedSceneView.cs

示例3: GetMouseButtons

		public static MouseButtons GetMouseButtons (NSEvent theEvent)
		{
			MouseButtons buttons = MouseButtons.None;
			
			switch (theEvent.Type)
			{
			case NSEventType.LeftMouseUp:
			case NSEventType.LeftMouseDown:
			case NSEventType.LeftMouseDragged:
				if ((theEvent.ModifierFlags & NSEventModifierMask.ControlKeyMask) > 0)
					buttons |= MouseButtons.Alternate;
				else
					buttons |= MouseButtons.Primary;
				break;
			case NSEventType.RightMouseUp:
			case NSEventType.RightMouseDown:
			case NSEventType.RightMouseDragged:
				buttons |= MouseButtons.Alternate;
				break;
			case NSEventType.OtherMouseUp:
			case NSEventType.OtherMouseDown:
			case NSEventType.OtherMouseDragged:
				buttons |= MouseButtons.Middle;
				break;
			}
			return buttons;
		}
开发者ID:majorsilence,项目名称:Eto,代码行数:27,代码来源:KeyMap.cs

示例4: GetLocation

		public static Point GetLocation (NSView view, NSEvent theEvent)
		{
			var loc = view.ConvertPointFromView (theEvent.LocationInWindow, null);
			if (!view.IsFlipped)
				loc.Y = view.Frame.Height - loc.Y;
			return Generator.ConvertF (loc);
		}
开发者ID:hultqvist,项目名称:Eto,代码行数:7,代码来源:Generator.cs

示例5: MenuForEvent

 //Handle right click event for the TableView
 public override NSMenu MenuForEvent (NSEvent theEvent)
 {
     CGPoint pt = this.ConvertPointFromView (theEvent.LocationInWindow, null);
     _selectedRow = this.GetRow (pt);
     NSTableViewDataSource ds = (NSTableViewDataSource)this.DataSource;
     NSMenu menu = new NSMenu ();
     if (_selectedRow >= (nint)0) {
         if (ds is NodesListView) {
             DirectoryNode node = ((ds as NodesListView).Entries [(int)_selectedRow] as DirectoryNode);
             if (node != null) {
                 if (node.NodeType == DirectoryNode.DirectoryNodeType.User) {
                     NSMenuItem ResetPassword = new NSMenuItem ("Set Password", node.RestUserPassword); 
                     menu.AddItem (ResetPassword);
                     NSMenuItem delete = new NSMenuItem ("Delete", node.Delete); 
                     menu.AddItem (delete);
                     NSMenuItem Properties = new NSMenuItem ("Properties", node.ViewProperties); 
                     menu.AddItem (Properties);
                 } else if (node.NodeType == DirectoryNode.DirectoryNodeType.Groups) {
                     NSMenuItem addUser = new NSMenuItem ("Add user to group", node.AddUserToGroup); 
                     menu.AddItem (addUser);
                 }
                
             }
         }
     }
     NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView);
     return base.MenuForEvent (theEvent);
 }
开发者ID:saberlilydian,项目名称:lightwave,代码行数:29,代码来源:VMDirTableView.cs

示例6: ExtendSelection

        public void ExtendSelection(NSTextView view, NSEvent evt)
        {
            int index = DoMouseEventToIndex(view, evt);

            NSRange range = view.selectedRange();
            if (range.length == 0 && index < view.string_().length() && view.string_()[index] == '\n')
            {
                // don't extend the selection if the user clicked off to the right side of a line
            }
            else if (index >= view.string_().length())
            {
                // don't extend the selection if the user clicked below the last line of text
                view.setSelectedRange(NSRange.Empty);
            }
            else
            {
                // Extend the selection so that it contains the entire word the user right-clicked on.
                if (range.length == 0 || !range.Intersects(index))
                {
                    range = new NSRange(index, 1);
                    range = view.selectionRangeForProposedRange_granularity(range, Enums.NSSelectByWord);
                    view.setSelectedRange(range);
                }
            }
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:25,代码来源:BuildTextContextMenu.cs

示例7: SwipeWithEvent

		public override void SwipeWithEvent (NSEvent theEvent)
		{
			// We are only interested in horizontal swipe
			if (theEvent.DeltaX == 0)
				return;
			FireSwipeEvent (theEvent.DeltaX > 0 ? SwipeSide.Left : SwipeSide.Right);
		}
开发者ID:jonlipsky,项目名称:monomac,代码行数:7,代码来源:WebViewExtraordinaire.cs

示例8: MouseMoved

		public override void MouseMoved (NSEvent theEvent)
		{
			if(theEvent == null)
				return;
			base.MouseMoved (theEvent);
			FireMouseMoved (theEvent);
		}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:MouseTemplate.g.cs

示例9: MouseDragged

		public override void MouseDragged (NSEvent theEvent)
		{
			PointF point = this.ConvertPointFromView (theEvent.LocationInWindow, null);
			this.Host.FireMouseMove (Host, new MouseEventArgs (MouseButtons.Left, theEvent.ClickCount, (int)point.X, (int)point.Y, 0));
			
			base.MouseDragged (theEvent);
		}
开发者ID:gabfr,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:ViewHelper.cs

示例10: RightMouseUp

		public override void RightMouseUp (NSEvent theEvent)
		{
			if(theEvent == null)
				return;
			base.RightMouseUp (theEvent);
			FireRightMouseUp(theEvent);
		}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:MouseTemplate.g.cs

示例11: RightMouseDragged

		public override void RightMouseDragged (NSEvent theEvent)
		{
			if(theEvent == null)
				return;
			base.RightMouseDragged (theEvent);
			RightMouseDragged (theEvent);
		}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:MouseTemplate.g.cs

示例12: MouseButtonUp

		public override void MouseButtonUp (NSEvent theEvent)
		{
			PointF ui_pt = ParentScreen.ScreenToLayer (theEvent.LocationInWindow);
			
			if (PointInside (ui_pt))
				OnActivate ();
		}
开发者ID:carriercomm,项目名称:scsharp,代码行数:7,代码来源:GrpButtonElement.cs

示例13: KeyboardDown

		public void KeyboardDown (NSEvent theEvent)
		{
			bool selection_changed = false;

			/* navigation keys */
			if (theEvent.CharactersIgnoringModifiers[0] == (char)NSKey.UpArrow) {
				if (cursor > 0) {
					cursor--;
					selection_changed = true;

					if (cursor < first_visible)
						first_visible = cursor;
				}
			}
			else if (theEvent.CharactersIgnoringModifiers[0] == (char)NSKey.DownArrow) {
				if (cursor < items.Count - 1) {
					cursor++;
					selection_changed = true;

					if (cursor >= first_visible + num_visible)
						first_visible = cursor - num_visible + 1;
				}
			}

			if (selection_changed) {
				Invalidate ();
				if (SelectionChanged != null)
					SelectionChanged (cursor);
			}
		}
开发者ID:carriercomm,项目名称:scsharp,代码行数:30,代码来源:ListBoxElement.cs

示例14: MouseUp

		public override void MouseUp (NSEvent theEvent)
		{
			if(theEvent == null)
				return;
			//base.MouseUp (theEvent);
			m_parent.HandleClick(theEvent.ClickCount,new MouseEventArgs(MouseButtons.Left,theEvent.ClickCount,theEvent.AbsoluteX,theEvent.AbsoluteY,theEvent.AbsoluteZ));
		}	
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:7,代码来源:Form.cocoa.cs

示例15: 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();
		}
开发者ID:remobjects,项目名称:TwinPeaks,代码行数:31,代码来源:TPGradientTableView.cs


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