private void OnButtonPress(object sender, ButtonPressEventArgs e) { try { timer.Stop(); if (e.Event.Button == 1 && e.Event.Type == Gdk.EventType.ButtonPress) { TreePath path; TreeViewColumn col; // Get the clicked location if (treeview1.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path, out col)) { // See if the click was on the current selection TreePath selPath; TreeViewColumn selCol; treeview1.GetCursor(out selPath, out selCol); if (selPath != null && path.Compare(selPath) == 0) { // Check where on the row we are located, allowing 16 pixels for the image, and 2 for its border Gdk.Rectangle rect = treeview1.GetCellArea(path, col); if (e.Event.X > rect.X + 18) { timer.Interval = treeview1.Settings.DoubleClickTime + 10; // We want this to be a bit longer than the double-click interval, which is normally 250 milliseconds timer.AutoReset = false; timer.Start(); } } } } } catch (Exception err) { ShowError(err); } }
private void OnTreeButtonDown(object sender, ButtonPressEventArgs args) { try { tree.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out TreePath path); if (args.Event.Button == 3 && tree.Selection.GetSelectedRows().Contains(path)) { args.RetVal = true; } } catch (Exception err) { ShowError(err); } }
void OnButtonPressed(object sender, Gtk.ButtonPressEventArgs args) { switch (args.Event.Button) { case 3: // third mouse button (right-click) Gtk.TreePath path = null; Gtk.TreeViewColumn column = null; if (tree.Selection.CountSelectedRows() == 0) { if (tree.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out path, out column) == false) { break; } Gtk.TreeIter iter; if (store_sort.GetIter(out iter, path) == false) { break; } tree.Selection.SelectIter(iter); } PopupContextMenuAtLocation((int)args.Event.X, (int)args.Event.Y); break; } }
private void OnTreeClicked(object sender, ButtonReleaseEventArgs e) { try { if (e.Event.Button == 1) // left click { Changed?.Invoke(sender, new EventArgs()); } else if (e.Event.Button == 3) // right click { TreePath path; tree.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path); // By default, Gtk will un-select the selected rows when a normal (non-shift/ctrl) click is registered. // Setting e.Retval to true will stop the default Gtk ButtonPress event handler from being called after // we return from this handler, which in turn means that the rows will not be deselected. e.RetVal = tree.Selection.GetSelectedRows().Contains(path); if (contextMenu != null) { contextMenu.ShowAll(); contextMenu.Popup(); } } } catch (Exception err) { ShowError(err); } }
private void TreeClicked(object sender, ButtonPressEventArgs e) { if (e.Event.Button == 3) // right click { contextMenu.Remove(run); string txt = ""; TreePath path; tree.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path); // By default, Gtk will un-select the selected rows when a normal (non-shift/ctrl) click is registered. // Setting e.Retval to true will stop the default Gtk ButtonPress event handler from being called after // we return from this handler, which in turn means that the rows will not be deselected. e.RetVal = tree.Selection.GetSelectedRows().Contains(path); // Get the grammar right if (tree.Selection.CountSelectedRows() == 1 || !(bool)e.RetVal) { txt = "Run this simulation"; } else { txt = "Run these simulations"; } run = new MenuItem(txt); run.ButtonPressEvent += RunSim; contextMenu.Add(run); contextMenu.ShowAll(); contextMenu.Popup(); } }
public static bool IsClickedNodeSelected(this Gtk.TreeView tree, int x, int y) { Gtk.TreePath path; if (tree.GetPathAtPos(x, y, out path)) { return(tree.Selection.PathIsSelected(path)); } return(false); }
private void TreeClicked(object sender, ButtonPressEventArgs e) { if (e.Event.Button == 3) // right click { TreePath path; tree.GetPathAtPos((int)e.Event.X, (int)e.Event.Y, out path); // By default, Gtk will un-select the selected rows when a normal (non-shift/ctrl) click is registered. // Setting e.Retval to true will stop the default Gtk ButtonPress event handler from being called after // we return from this handler, which in turn means that the rows will not be deselected. e.RetVal = tree.Selection.GetSelectedRows().Contains(path); contextMenu.ShowAll(); contextMenu.Popup(); } }
public void OnTransferListButtonPressEvent(object o, Gtk.ButtonPressEventArgs args) { TreePath path; if (transferList.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out path)) { transferList.Selection.SelectPath(path); } else { transferList.Selection.UnselectAll(); } if (args.Event.Button == 3) { TransfersMenu transfersMenu = new TransfersMenu(transferList, GetSelectedTransfer()); transfersMenu.Popup(); } }