protected override bool OnButtonPressEvent(EventButton evnt) { if (evnt.Button != 1 || evnt.IsContextMenuButton()) { return(base.OnButtonPressEvent(evnt)); } if (IsOverIndicator(evnt.Y)) { parentStrip.GotoTask(parentStrip.SearchNextTask(GetHoverMode())); return(base.OnButtonPressEvent(evnt)); } var hoverTask = GetHoverTask(evnt.Y); if (hoverTask != null) { MoveToTask(hoverTask); } if (IsInsideBar(evnt.X, evnt.Y)) { Grab.Add(this); grabCenter = GetSliderCenter(); grabY = evnt.Y; } else { MovePosition(evnt.Y); } return(base.OnButtonPressEvent(evnt)); }
public static void GrabWindow(Window window) { window.GrabFocus(); Grab.Add(window); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(window.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(window); window.Destroy(); } } else { Grab.Remove(window); window.Destroy(); } }
protected override void OnMapped() { base.OnMapped(); Gdk.Pointer.Grab(GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask, null, null, Global.CurrentEventTime); Grab.Add(this); GrabBrokenEvent += delegate { Destroy(); }; }
protected override bool OnButtonPressEvent(EventButton evnt) { int px = (int)evnt.X - x_offset; int py = (int)evnt.Y - y_offset; if (px < 0) { px = 0; } if (px > width - 1) { px = width - 1; } if (py < 0) { py = 0; } if (py > height - 1) { py = height - 1; } //find the closest point float closest_x = MinX - 1; var distance = int.MaxValue; foreach (var point in points) { int cx = Project(point.Key, MinX, MaxX, width); if (Math.Abs(px - cx) < distance) { distance = Math.Abs(px - cx); closest_x = point.Key; } } Grab.Add(this); CursorType = CursorType.Tcross; switch (CurveType) { case CurveType.Linear: case CurveType.Spline: if (distance > min_distance) { //insert a new control point AddPoint((closest_x = Unproject(px, MinX, MaxX, width)), MaxY - Unproject(py, MinY, MaxY, height)); QueueDraw(); } grab_point = closest_x; break; case CurveType.Free: throw new NotImplementedException(); } return(true); }
private void ShowPopup() { win = new Gtk.Window(Gtk.WindowType.Popup); win.Screen = this.Screen; win.WidthRequest = this.Allocation.Width; cal = new Gtk.Calendar(); win.Add(cal); if (validDate) { cal.Date = date; } // events win.ButtonPressEvent += OnWinButtonPressEvent; cal.DaySelectedDoubleClick += OnCalDaySelectedDoubleClick; cal.KeyPressEvent += OnCalKeyPressEvent; cal.ButtonPressEvent += OnCalButtonPressEvent; int x, y; GetWidgetPos(this, out x, out y); win.Move(x, y + Allocation.Height + 2); win.ShowAll(); win.GrabFocus(); Grab.Add(win); Gdk.GrabStatus grabStatus; grabStatus = Gdk.Pointer.Grab(win.GdkWindow, true, EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask, null, null, Gtk.Global.CurrentEventTime); if (grabStatus == Gdk.GrabStatus.Success) { grabStatus = Gdk.Keyboard.Grab(win.GdkWindow, true, Gtk.Global.CurrentEventTime); if (grabStatus != Gdk.GrabStatus.Success) { Grab.Remove(win); win.Destroy(); win = null; } } else { Grab.Remove(win); win.Destroy(); win = null; } }
void OnMotionNotify(object obj, MotionNotifyEventArgs args) { if (!DragInProgress) { DragInProgress = true; Grab.Add(this); if (!Pointer.IsGrabbed) { Pointer.Grab(ParentWindow, false, EventMask.Button1MotionMask | EventMask.ButtonReleaseMask, null, fleurCursor, args.Event.Time); } } MoveTab(FindTabAtPosition(args.Event.XRoot, args.Event.YRoot)); }
void HandleCalendarButtonClicked(object sender, EventArgs e) { //Temporarily grab pointer and keyboard if (!GrabPointerAndKeyboard(GdkWindow, Gtk.Global.CurrentEventTime)) { return; } //select the day on the calendar PositionPopup(); Grab.Add(calendar_popup); calendar_popup.Show(); calendar.GrabFocus(); //transfer the grabs to the popup GrabPointerAndKeyboard(calendar_popup.GdkWindow, Gtk.Global.CurrentEventTime); }
private void StartDrag() { if (!IsRealized) { Realize(); } DockObjectFlags |= DockObjectFlags.InDrag; /* grab the pointer so we receive all mouse events */ //Gdk.Cursor fleur = new Gdk.Cursor (Gdk.CursorType.Fleur); /* grab the keyboard & pointer */ Grab.Add(this); OnDragBegin(); DockItemDragBeginHandler handler = DockItemDragBegin; if (handler != null) { handler(this); } }
private void ShowCalendar() { popup = new Window(WindowType.Popup); popup.Screen = tree.Screen; Frame frame = new Frame(); frame.Shadow = ShadowType.Out; frame.Show(); popup.Add(frame); VBox box = new VBox(false, 0); box.Show(); frame.Add(box); cal = new Calendar(); cal.DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers; cal.KeyPressEvent += OnCalendarKeyPressed; popup.ButtonPressEvent += OnButtonPressed; cal.Show(); Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); calAlignment.Show(); calAlignment.SetPadding(4, 4, 4, 4); calAlignment.Add(cal); box.PackStart(calAlignment, false, false, 0); // FIXME: Make the popup appear directly below the date Gdk.Rectangle allocation = tree.Allocation; // Gtk.Requisition req = tree.SizeRequest (); int x = 0, y = 0; tree.GdkWindow.GetOrigin(out x, out y); // popup.Move(x + allocation.X, y + allocation.Y + req.Height + 3); popup.Move(x + allocation.X, y + allocation.Y); popup.Show(); popup.GrabFocus(); Grab.Add(popup); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(popup.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(popup); popup.Destroy(); popup = null; } } else { Grab.Remove(popup); popup.Destroy(); popup = null; } cal.DaySelectedDoubleClick += OnCalendarDaySelected; cal.ButtonPressEvent += OnCalendarButtonPressed; cal.Date = date == DateTime.MinValue ? DateTime.Now : date; }
private void ShowCalendar() { popup = new Window(WindowType.Popup); popup.Screen = this.Screen; Frame frame = new Frame(); frame.ShadowType = ShadowType.Out; frame.Show(); popup.Add(frame); VBox box = new VBox(false, 0); box.Show(); frame.Add(box); cal = new Calendar(); cal.DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers; cal.KeyPressEvent += OnCalendarKeyPressed; popup.ButtonPressEvent += OnButtonPressed; cal.Show(); Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); calAlignment.Show(); calAlignment.SetPadding(4, 4, 4, 4); calAlignment.Add(cal); box.PackStart(calAlignment, false, false, 0); int minimum_height, natural_height; GetPreferredHeight(out minimum_height, out natural_height); int x = 0, y = 0; Window.GetOrigin(out x, out y); popup.Move(x + Allocation.X, y + Allocation.Y + natural_height + 3); popup.Show(); popup.GrabFocus(); Grab.Add(popup); Gdk.Device event_device = Gtk.Global.CurrentEventDevice; if (event_device.Source == Gdk.InputSource.Mouse) { pointer = event_device; keyboard = event_device.AssociatedDevice; } else { keyboard = event_device; pointer = event_device.AssociatedDevice; } Gdk.GrabStatus grabbed = pointer.Grab(popup.Window, Gdk.GrabOwnership.Application, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = keyboard.Grab(popup.Window, Gdk.GrabOwnership.Application, true, Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask, null, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(popup); popup.Destroy(); popup = null; } } else { Grab.Remove(popup); popup.Destroy(); popup = null; } cal.DaySelectedDoubleClick += OnCalendarDaySelected; cal.ButtonPressEvent += OnCalendarButtonPressed; cal.Date = date; }
public void ShowCalendar() { popup = new Window(WindowType.Popup); popup.Screen = parent.Screen; Frame frame = new Frame(); frame.Shadow = ShadowType.Out; frame.Show(); popup.Add(frame); VBox box = new VBox(false, 0); box.Show(); frame.Add(box); cal = new Calendar(); cal.DisplayOptions = CalendarDisplayOptions.ShowHeading | CalendarDisplayOptions.ShowDayNames | CalendarDisplayOptions.ShowWeekNumbers; cal.KeyPressEvent += OnCalendarKeyPressed; popup.ButtonPressEvent += OnButtonPressed; cal.Show(); Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f); calAlignment.Show(); calAlignment.SetPadding(4, 4, 4, 4); calAlignment.Add(cal); box.PackStart(calAlignment, false, false, 0); //Requisition req = SizeRequest(); parent.GdkWindow.GetOrigin(out xPos, out yPos); // popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3); popup.Move(xPos, yPos); popup.Show(); popup.GrabFocus(); Grab.Add(popup); Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME); if (grabbed == Gdk.GrabStatus.Success) { grabbed = Gdk.Keyboard.Grab(popup.GdkWindow, true, CURRENT_TIME); if (grabbed != Gdk.GrabStatus.Success) { Grab.Remove(popup); popup.Destroy(); popup = null; } } else { Grab.Remove(popup); popup.Destroy(); popup = null; } cal.DaySelected += OnCalendarDaySelected; cal.MonthChanged += OnCalendarMonthChanged; cal.Date = date; }