예제 #1
0
        public static bool HandleMouseDown(this IViewObject view, NSEvent theEvent)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }
            if (theEvent == null)
            {
                throw new ArgumentNullException(nameof(theEvent));
            }
            if (view.View == null)
            {
                throw new InvalidOperationException();
            }
            CGPoint p = view.View.ConvertPointFromEvent(theEvent);

            if (!view.View.Bounds.Contains(p))
            {
                return(false);
            }
            ButtonEventArgs args = new ButtonEventArgs();

            args.X      = p.X;
            args.Y      = p.Y;
            args.Button = theEvent.GetPointerButton();
            args.IsContextMenuTrigger = theEvent.TriggersContextMenu();
            args.MultiplePress        = (int)theEvent.ClickCount;
            view.Backend.ApplicationContext.InvokeUserCode(delegate
            {
                view.Backend.EventSink.OnButtonPressed(args);
            });
            return(args.Handled);
        }
예제 #2
0
파일: CellUtil.cs 프로젝트: miryamGSM/xwt
 public static bool HandleMouseUp(this ICellRenderer cell, NSEvent theEvent)
 {
     if (cell.Backend.GetIsEventEnabled(WidgetEvent.ButtonReleased))
     {
         CGPoint p = cell.CellView.ConvertPointFromEvent(theEvent);
         if (cell.CellView.Bounds.Contains(p))
         {
             cell.Backend.Load(cell);
             cell.CellContainer.SetCurrentEventRow();
             ButtonEventArgs args = new ButtonEventArgs {
                 X             = p.X,
                 Y             = p.Y,
                 Button        = theEvent.GetPointerButton(),
                 MultiplePress = (int)theEvent.ClickCount
             };
             cell.Backend.Context.InvokeUserCode(() => cell.Backend.EventSink.OnButtonReleased(args));
             return(args.Handled);
         }
     }
     return(false);
 }