void OnTabPress(object s, Gtk.ButtonPressEventArgs args) { CurrentTab = Array.IndexOf(box.Children.ToArray(), s); DockItemTitleTab t = (DockItemTitleTab)s; DockItem.SetFocus(t.Page); QueueDraw(); args.RetVal = true; }
public void Present(bool giveFocus) { AutoShow(); if (giveFocus) { GLib.Timeout.Add(200, delegate { // Using a small delay because AutoShow uses an animation and setting focus may // not work until the item is visible it.SetFocus(); ScheduleAutoHide(false); return(false); }); } }
public TabSelector(bool active) { Active = active; ActiveIndex = -1; mTracker = new MouseTracker(this) { MotionEvents = true, EnterLeaveEvents = true, ButtonPressedEvents = true }; mTracker.EnterNotify += (sender, e) => { QueueDraw(); }; mTracker.LeaveNotify += (sender, e) => { QueueDraw(); }; mTracker.MouseMoved += (sender, e) => { QueueDraw(); }; mTracker.ButtonPressed += (sender, e) => { if (e.Event.TriggersContextMenu()) { int index; if (CalculateIndexAtPosition(mTracker.MousePosition.X, out index)) { var t = mTabs.ElementAt(index).DockItemTitleTab; if (t != null) { t.item.ShowDockPopupMenu(e.Event.Time, this); } } } else if (e.Event.Button == 1 && e.Event.Type == Gdk.EventType.ButtonPress) { int index; if (CalculateIndexAtPosition(mTracker.MousePosition.X, out index)) { if (ActiveIndex != index) { ActiveIndex = index; CurrentTab = ActiveIndex; if (SelectTab != null) { SelectTab(this, new SelectTabEventArgs(ActiveIndex, true)); } QueueDraw(); } // else { tabPressed = true; pressX = e.Event.X; pressY = e.Event.Y; } } } }; mTracker.ButtonReleased += (sender, e) => { const int LEFT_MOUSE_BUTTON = 1; var t = mTabs.ElementAt(m_CurrentTab).DockItemTitleTab; if (tabActivated) { tabActivated = false; if (t.item.Status == DockItemStatus.AutoHide) { t.item.Status = DockItemStatus.Dockable; } else { t.item.Status = DockItemStatus.AutoHide; } } else if (!e.Event.TriggersContextMenu() && e.Event.Button == LEFT_MOUSE_BUTTON) { t.frame.DockInPlaceholder(t.item); t.frame.HidePlaceholder(); if (GdkWindow != null) { GdkWindow.Cursor = null; } t.frame.Toplevel.KeyPressEvent -= HeaderKeyPress; t.frame.Toplevel.KeyReleaseEvent -= HeaderKeyRelease; DockItem.SetFocus(t.Page); } tabPressed = false; }; mTracker.MouseMoved += (sender, e) => { if (m_CurrentTab != -1) { var t = mTabs.ElementAt(m_CurrentTab).DockItemTitleTab; if (tabPressed && !t.item.Behavior.HasFlag(DockItemBehavior.NoGrip) && Math.Abs(e.Event.X - pressX) > 3 && Math.Abs(e.Event.Y - pressY) > 3) { t.frame.ShowPlaceholder(t.item); GdkWindow.Cursor = fleurCursor; t.frame.Toplevel.KeyPressEvent += HeaderKeyPress; t.frame.Toplevel.KeyReleaseEvent += HeaderKeyRelease; allowPlaceholderDocking = true; tabPressed = false; } t.frame.UpdatePlaceholder(t.item, Allocation.Size, allowPlaceholderDocking); } }; }
internal void Present(DockItem it, bool giveFocus) { if (type == DockGroupType.Tabbed) { for (int n=0; n<VisibleObjects.Count; n++) { DockGroupItem dit = VisibleObjects[n] as DockGroupItem; if (dit.Item == it) { currentTabPage = n; if (boundTabStrip != null) boundTabStrip.CurrentPage = it.Widget; break; } } } if (giveFocus && it.Visible) it.SetFocus (); }