Ejemplo n.º 1
0
        static void HandleActivated(object sender, EventArgs e)
        {
            var handler = GetHandler(sender) as SliderHandler;

            if (handler != null)
            {
                var newval = (int)Math.Round(handler.Control.DoubleValue);
                if (newval != handler.Control.IntValue)
                {
                    handler.Control.IntValue = newval;
                }

                handler.Callback.OnValueChanged(handler.Widget, EventArgs.Empty);

                var ev = NSApplication.SharedApplication.CurrentEvent;
                if (ev != null)
                {
                    // trigger mouse events when value is changed as they are buried by the slider
                    if (ev.Type == NSEventType.LeftMouseUp || ev.Type == NSEventType.RightMouseUp)
                    {
                        handler.Callback.OnMouseUp(handler.Widget, MacConversions.GetMouseEvent(handler.Control, ev, false));
                    }
                    else if (ev.Type == NSEventType.LeftMouseDragged || ev.Type == NSEventType.RightMouseDragged)
                    {
                        handler.Callback.OnMouseMove(handler.Widget, MacConversions.GetMouseEvent(handler.Control, ev, false));
                    }
                }
            }
        }
Ejemplo n.º 2
0
            public override void SelectionIsChanging(NSNotification notification)
            {
                var theEvent = NSApplication.SharedApplication.CurrentEvent;

                if (theEvent.ButtonMask != 0)
                {
                    // user is dragging the mouse, fire mouse move notifications
                    var args = MacConversions.GetMouseEvent(Handler.ContainerControl, theEvent, false);
                }
            }
Ejemplo n.º 3
0
            public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard)
            {
                var h = Handler;

                if (h == null)
                {
                    return(false);
                }

                if (h.IsMouseDragging)
                {
                    h.DragInfo = null;
                    // give MouseMove event a chance to start the drag
                    h.DragPasteboard = pboard;


                    // check if the dragged rows are different than the selection so we can fire a changed event
                    var  dragRows             = rowIndexes.Select(r => (int)r).ToList();
                    bool isDifferentSelection = (nint)dragRows.Count != h.Control.SelectedRowCount;
                    if (!isDifferentSelection)
                    {
                        // same count, ensure they're not different rows
                        // typically only tests one entry here, as there's no way to drag more than a single non-selected item.
                        var selectedRows = h.Control.SelectedRows.ToArray();
                        for (var i = 0; i < selectedRows.Length; i++)
                        {
                            if (!dragRows.Contains((int)selectedRows[i]))
                            {
                                isDifferentSelection = true;
                                break;
                            }
                        }
                    }

                    if (isDifferentSelection)
                    {
                        h.CustomSelectedRows = dragRows;
                        h.Callback.OnSelectionChanged(h.Widget, EventArgs.Empty);
                    }

                    var args = MacConversions.GetMouseEvent(h, NSApplication.SharedApplication.CurrentEvent, false);
                    h.Callback.OnMouseMove(h.Widget, args);
                    h.DragPasteboard = null;

                    return(h.DragInfo != null);
                }

                return(false);
            }
Ejemplo n.º 4
0
            public override void MouseDown(NSEvent theEvent)
            {
                var handler = Handler;

                if (handler != null)
                {
                    var args = MacConversions.GetMouseEvent(handler.ContainerControl, theEvent, false);
                    if (theEvent.ClickCount >= 2)
                    {
                        handler.Callback.OnMouseDoubleClick(handler.Widget, args);
                    }
                    else
                    {
                        handler.Callback.OnMouseDown(handler.Widget, args);
                    }
                    if (args.Handled)
                    {
                        return;
                    }

                    var point    = ConvertPointFromView(theEvent.LocationInWindow, null);
                    int rowIndex = (int)GetRow(point);
                    if (rowIndex >= 0)
                    {
                        int columnIndex = (int)GetColumn(point);
                        var item        = handler.GetItem(rowIndex);
                        var column      = columnIndex == -1 || columnIndex > handler.Widget.Columns.Count ? null : handler.Widget.Columns[columnIndex];
                        var cellArgs    = MacConversions.CreateCellMouseEventArgs(column, handler.ContainerControl, rowIndex, columnIndex, item, theEvent);
                        if (theEvent.ClickCount >= 2)
                        {
                            handler.Callback.OnCellDoubleClick(handler.Widget, cellArgs);
                        }
                        else
                        {
                            handler.Callback.OnCellClick(handler.Widget, cellArgs);
                        }
                    }
                    handler.IsMouseDragging = true;
                    base.MouseDown(theEvent);
                    handler.IsMouseDragging = false;

                    // NSOutlineView uses an event loop and MouseUp() does not get called
                    handler.Callback.OnMouseUp(handler.Widget, args);

                    return;
                }
                base.MouseDown(theEvent);
            }
Ejemplo n.º 5
0
        static void TriggerMouseDragged(IntPtr sender, IntPtr sel, IntPtr e)
        {
            var obj     = Runtime.GetNSObject(sender);
            var handler = GetHandler(obj) as IMacViewHandler;

            if (handler != null)
            {
                var theEvent = Messaging.GetNSObject <NSEvent>(e);
                var args     = MacConversions.GetMouseEvent(handler.ContainerControl, theEvent, false);
                handler.Callback.OnMouseMove(handler.Widget, args);
                if (!args.Handled)
                {
                    Messaging.void_objc_msgSendSuper_IntPtr(obj.SuperHandle, sel, e);
                }
            }
        }
Ejemplo n.º 6
0
Archivo: MacView.cs Proyecto: yaram/Eto
        /// <summary>
        /// Triggers a mouse callback from a different event.
        /// e.g. when an NSButton is clicked it is triggered from a mouse up event.
        /// </summary>
        protected void TriggerMouseCallback()
        {
            // trigger mouse up event since it's buried by cocoa
            var evt = NSApplication.SharedApplication.CurrentEvent;

            if (evt == null)
            {
                return;
            }
            if (evt.Type == NSEventType.LeftMouseUp || evt.Type == NSEventType.RightMouseUp || evt.Type == NSEventType.OtherMouseUp)
            {
                Callback.OnMouseUp(Widget, MacConversions.GetMouseEvent(ContainerControl, evt, false));
            }
            if (evt.Type == NSEventType.LeftMouseDragged || evt.Type == NSEventType.RightMouseDragged || evt.Type == NSEventType.OtherMouseDragged)
            {
                Callback.OnMouseMove(Widget, MacConversions.GetMouseEvent(ContainerControl, evt, false));
            }
        }
Ejemplo n.º 7
0
            bool HandleMouseEvent(NSEvent theEvent)
            {
                var handler = Handler;

                if (handler != null)
                {
                    var args = MacConversions.GetMouseEvent(handler, theEvent, false);
                    if (theEvent.ClickCount >= 2)
                    {
                        handler.Callback.OnMouseDoubleClick(handler.Widget, args);
                    }
                    else
                    {
                        handler.Callback.OnMouseDown(handler.Widget, args);
                    }
                    if (args.Handled)
                    {
                        return(true);
                    }

                    var point = ConvertPointFromView(theEvent.LocationInWindow, null);

                    int rowIndex;
                    if ((rowIndex = (int)GetRow(point)) >= 0)
                    {
                        int columnIndex = (int)GetColumn(point);
                        var item        = handler.GetItem(rowIndex);
                        var column      = columnIndex == -1 || columnIndex > handler.Widget.Columns.Count ? null : handler.Widget.Columns[columnIndex];
                        var cellArgs    = MacConversions.CreateCellMouseEventArgs(column, handler.ContainerControl, rowIndex, columnIndex, item, theEvent);
                        if (theEvent.ClickCount >= 2)
                        {
                            handler.Callback.OnCellDoubleClick(handler.Widget, cellArgs);
                        }
                        else
                        {
                            handler.Callback.OnCellClick(handler.Widget, cellArgs);
                        }
                    }
                }
                return(false);
            }
Ejemplo n.º 8
0
            public override bool WriteRows(NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard)
            {
                var h = Handler;

                if (h == null)
                {
                    return(false);
                }

                if (h.IsMouseDragging)
                {
                    h.Control.AllowedOperation = null;
                    // give MouseMove event a chance to start the drag
                    h.DragPasteboard     = pboard;
                    h.CustomSelectedRows = rowIndexes.Select(r => (int)r).ToList();
                    var args = MacConversions.GetMouseEvent(h.ContainerControl, NSApplication.SharedApplication.CurrentEvent, false);
                    h.Callback.OnMouseMove(h.Widget, args);
                    h.DragPasteboard     = null;
                    h.CustomSelectedRows = null;
                    return(h.Control.AllowedOperation != null);
                }

                return(false);
            }
Ejemplo n.º 9
0
            public override bool OutlineViewwriteItemstoPasteboard(NSOutlineView outlineView, NSArray items, NSPasteboard pboard)
            {
                var h = Handler;

                if (h == null)
                {
                    return(false);
                }

                if (h.IsMouseDragging)
                {
                    h.Control.AllowedOperation = null;
                    // give MouseMove event a chance to start the drag
                    h.DragPasteboard      = pboard;
                    h.CustomSelectedItems = GetItems(items).ToList();
                    var args = MacConversions.GetMouseEvent(h.ContainerControl, NSApplication.SharedApplication.CurrentEvent, false);
                    h.Callback.OnMouseMove(h.Widget, args);
                    h.DragPasteboard      = null;
                    h.CustomSelectedItems = null;
                    return(h.Control.AllowedOperation != null);
                }

                return(false);
            }
Ejemplo n.º 10
0
 public void ScrollWheel(NSEvent theEvent)
 {
     Handler.Callback.OnMouseWheel(Handler.Widget, MacConversions.GetMouseEvent(Handler.EventControl, theEvent, true));
 }
Ejemplo n.º 11
0
 public void MouseExited(NSEvent theEvent)
 {
     Handler.Callback.OnMouseLeave(Handler.Widget, MacConversions.GetMouseEvent(Handler.EventControl, theEvent, false));
 }