本文整理汇总了C#中Gtk.MenuItem.AddAccelerator方法的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.AddAccelerator方法的具体用法?C# MenuItem.AddAccelerator怎么用?C# MenuItem.AddAccelerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.MenuItem
的用法示例。
在下文中一共展示了MenuItem.AddAccelerator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNoteOpened
public override void OnNoteOpened()
{
item = new Gtk.MenuItem (Catalog.GetString ("Insert Code Snippet"));
item.Activated += OnMenuItemActivated;
item.AddAccelerator ("activate", Window.AccelGroup,
(uint)Gdk.Key.d, Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
item.Show ();
AddPluginMenuItem (item);
Window.Editor.DeleteFromCursor += OnDeleteRange;
Window.Editor.Backspace += OnBackspace;
Window.Editor.MoveCursor += OnMoveCursor;
Window.Editor.FocusInEvent += OnFocusIn;
Window.Editor.FocusOutEvent += OnFocusOut;
checkCodeSnippet ();
cs_changed = false;
}
示例2: CreateShortcutsBar
private MenuBar CreateShortcutsBar()
{
// Adds a hidden menubar that contains to enable keyboard
// shortcuts to close the log
MenuBar menu_bar = new MenuBar ();
MenuItem file_item = new MenuItem ("File");
Menu file_menu = new Menu ();
MenuItem close_1 = new MenuItem ("Close1");
MenuItem close_2 = new MenuItem ("Close2");
// adds specific Ctrl+W and Esc key accelerators to Log Window
AccelGroup accel_group = new AccelGroup ();
AddAccelGroup (accel_group);
// Close on Esc
close_1.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.W, Gdk.ModifierType.ControlMask,
AccelFlags.Visible));
close_1.Activated += delegate { HideAll (); };
// Close on Ctrl+W
close_2.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.Escape, Gdk.ModifierType.None,
AccelFlags.Visible));
close_2.Activated += delegate { HideAll (); };
file_menu.Append (close_1);
file_menu.Append (close_2);
file_item.Submenu = file_menu;
menu_bar.Append (file_item);
// Hacky way to hide the menubar, but the accellerators
// will simply be disabled when using Hide ()
menu_bar.HeightRequest = 1;
menu_bar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal));
return menu_bar;
}
示例3: SparkleLog
public SparkleLog(string path)
: base("")
{
LocalPath = path;
string name = System.IO.Path.GetFileName (LocalPath);
SetDefaultSize (480, 640);
SetPosition (WindowPosition.Center);
BorderWidth = 0;
// TRANSLATORS: {0} is a folder name, and {1} is a server address
Title = String.Format(_("Recent Events in ‘{0}’"), name);
IconName = "folder-sparkleshare";
DeleteEvent += delegate {
Close ();
};
// Adds a hidden menubar that contains to enable keyboard
// shortcuts to close the log
MenuBar = new MenuBar ();
MenuItem file_item = new MenuItem ("File");
Menu file_menu = new Menu ();
MenuItem close_1 = new MenuItem ("Close1");
MenuItem close_2 = new MenuItem ("Close2");
// adds specific Ctrl+W and Esc key accelerators to Log Window
AccelGroup accel_group = new AccelGroup ();
AddAccelGroup (accel_group);
// Close on Esc
close_1.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.W, Gdk.ModifierType.ControlMask,
AccelFlags.Visible));
close_1.Activated += delegate { Close (); };
// Close on Ctrl+W
close_2.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.Escape, Gdk.ModifierType.None,
AccelFlags.Visible));
close_2.Activated += delegate { Close (); };
file_menu.Append (close_1);
file_menu.Append (close_2);
file_item.Submenu = file_menu;
MenuBar.Append (file_item);
// Hacky way to hide the menubar, but the accellerators
// will simply be disabled when using Hide ()
MenuBar.HeightRequest = 1;
MenuBar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal));
LayoutVertical = new VBox (false, 0);
LayoutVertical.PackStart (CreateEventLog (), true, true, 0);
HButtonBox dialog_buttons = new HButtonBox {
Layout = ButtonBoxStyle.Edge,
BorderWidth = 12
};
Button open_folder_button = new Button (_("_Open Folder")) {
UseUnderline = true
};
open_folder_button.Clicked += delegate (object o, EventArgs args) {
Process process = new Process ();
process.StartInfo.FileName = Defines.OPEN_COMMAND;
process.StartInfo.Arguments = LocalPath.Replace (" ", "\\ "); // Escape space-characters
process.Start ();
Close ();
};
Button close_button = new Button (Stock.Close);
close_button.Clicked += delegate {
Close ();
};
dialog_buttons.Add (open_folder_button);
dialog_buttons.Add (close_button);
LayoutVertical.PackStart (new HSeparator (), false, false, 0);
// We have to hide the menubar somewhere...
LayoutVertical.PackStart (MenuBar, false, false, 0);
LayoutVertical.PackStart (dialog_buttons, false, false, 0);
Add (LayoutVertical);
}
示例4: Browser
public Browser (string basedir, IEnumerable<string> sources, string engine)
{
#if MACOS
try {
InitMacAppHandlers();
} catch (Exception ex) {
Console.Error.WriteLine ("Installing Mac AppleEvent handlers failed. Skipping.\n" + ex);
}
#endif
this.engine = engine;
ui = new Glade.XML (null, "browser.glade", "window1", null);
ui.Autoconnect (this);
MainWindow = (Gtk.Window) ui["window1"];
MainWindow.DeleteEvent += new DeleteEventHandler (delete_event_cb);
MainWindow.KeyPressEvent += new KeyPressEventHandler (keypress_event_cb);
MainWindow.KeyReleaseEvent += new KeyReleaseEventHandler (keyrelease_event_cb);
Stream icon = GetResourceImage ("monodoc.png");
if (icon != null) {
monodoc_pixbuf = new Gdk.Pixbuf (icon);
MainWindow.Icon = monodoc_pixbuf;
}
//ellipsizing label for the title
title_label = new ELabel ("");
title_label.Xalign = 0;
Pango.FontDescription fd = new Pango.FontDescription ();
fd.Weight = Pango.Weight.Bold;
title_label.ModifyFont (fd);
title_label.Layout.FontDescription = fd;
title_label_box.Add (title_label);
title_label.Show ();
//colour the bar according to the current style
bar_style = bar_eb.Style.Copy ();
bar_eb.Style = bar_style;
MainWindow.StyleSet += new StyleSetHandler (BarStyleSet);
BarStyleSet (null, null);
help_tree = Driver.LoadTree (basedir, sources);
tree_browser = new TreeBrowser (help_tree, reference_tree, this);
// Bookmark Manager init;
bookmark_manager = new BookmarkManager(this);
//
// Tab Notebook and first tab
//
tabs_nb = new Notebook(); //the Notebook that holds tabs
tabs_nb.Scrollable = true;
tabs_nb.SwitchPage += new SwitchPageHandler(ChangeTab);
help_container.Add(tabs_nb);
AddTab();
if ((capabilities & Capabilities.Fonts) != 0) {
// Add Menu entries for changing the font
Menu aux = (Menu) view1.Submenu;
MenuItem sep = new SeparatorMenuItem ();
sep.Show ();
aux.Append (sep);
AccelGroup accel = new AccelGroup ();
MainWindow.AddAccelGroup (accel);
textLarger = new MenuItem ("_Larger text");
textLarger.Activated += new EventHandler (TextLarger);
textLarger.Show ();
aux.Append (textLarger);
AccelKey ak = new AccelKey (Gdk.Key.plus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
textLarger.AddAccelerator ("activate", accel, ak);
textSmaller = new MenuItem ("_Smaller text");
textSmaller.Activated += new EventHandler (TextSmaller);
textSmaller.Show ();
aux.Append (textSmaller);
ak = new AccelKey (Gdk.Key.minus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
textSmaller.AddAccelerator ("activate", accel, ak);
textNormal = new MenuItem ("_Original size");
textNormal.Activated += new EventHandler (TextNormal);
textNormal.Show ();
aux.Append (textNormal);
ak = new AccelKey (Gdk.Key.Key_0, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
textNormal.AddAccelerator ("activate", accel, ak);
}
// restore the editing setting
editing1.Active = SettingsHandler.Settings.EnableEditing;
comments1.Active = SettingsHandler.Settings.ShowComments;
cut1.Sensitive = false;
paste1.Sensitive = false;
//
//.........这里部分代码省略.........
示例5: CreateDebuggerMenu
// Create "Debugger" menu
MenuItem CreateDebuggerMenu(AccelGroup agr)
{
MenuItem dbg = new MenuItem("_Debugger");
Menu dbgMenu = new Menu();
dbg.Submenu = dbgMenu;
debuggerStart = new MenuItem("_Start debugger");
debuggerStart.Activated += OnDebuggerStart;
debuggerStart.AddAccelerator("activate", agr,
new AccelKey(Gdk.Key.F5, Gdk.ModifierType.None,
AccelFlags.Visible));
dbgMenu.Append(debuggerStart);
debuggerStop = new MenuItem("_Stop debugger");
debuggerStop.Activated += OnDebuggerStop;
debuggerStop.AddAccelerator("activate", agr,
new AccelKey(Gdk.Key.F6, Gdk.ModifierType.None,
AccelFlags.Visible));
dbgMenu.Append(debuggerStop);
debuggerInterrupt = new ImageMenuItem(Stock.Cancel, agr);
((Label)debuggerInterrupt.Children[0]).Text = "Interrupt execution";
debuggerInterrupt.AddAccelerator("activate", agr,
new AccelKey(Gdk.Key.F9, Gdk.ModifierType.None,
AccelFlags.Visible));
debuggerInterrupt.Activated += OnDebuggerInterrupt;
dbgMenu.Append(debuggerInterrupt);
dbgMenu.Append(CreateCommandsMenu(agr));
return dbg;
}
示例6: Initialize
public override void Initialize()
{
itemInsert = new Gtk.MenuItem(Catalog.GetString("Insert checkbox"));
itemInsert.Activated += OnMenuItemActivatedUnmarked;
itemInsert.Show();
AddPluginMenuItem(itemInsert);
itemMarked = new Gtk.MenuItem(Catalog.GetString("Insert marked checkbox"));
itemMarked.Activated += OnMenuItemActivatedMarked;
itemMarked.Show();
AddPluginMenuItem(itemMarked);
itemXMarked = new Gtk.MenuItem(Catalog.GetString("Insert X marked checkbox"));
itemXMarked.Activated += OnMenuItemActivatedXMarked;
itemXMarked.Show();
AddPluginMenuItem(itemXMarked);
itemTick = new Gtk.MenuItem(Catalog.GetString("Insert tick"));
itemTick.Activated += OnMenuItemActivatedTick;
itemTick.Show();
AddPluginMenuItem(itemTick);
itemBallot = new Gtk.MenuItem(Catalog.GetString("Insert X ballot"));
itemBallot.Activated += OnMenuItemActivatedBallotX;
itemBallot.Show();
AddPluginMenuItem(itemBallot);
itemToggle = new Gtk.MenuItem(Catalog.GetString("Toggle checkmark"));
itemToggle.Activated += OnMenuItemActivatedToggle;
AddPluginMenuItem(itemToggle);
Gtk.AccelGroup accel_group = new Gtk.AccelGroup();
Window.AddAccelGroup(accel_group);
itemToggle.AddAccelerator("activate", accel_group,
new AccelKey(Gdk.Key.m,
Gdk.ModifierType.ControlMask,
AccelFlags.Visible));
itemToggle.Show();
}
示例7: AddAccelerator
/// <summary>
/// Add a keybinding for this keybinder's AccelGroup.
/// </summary>
/// <param name="handler">
/// A <see cref="EventHandler"/> for when the keybinding is
/// activated.
/// </param>
/// <param name="key">
/// A <see cref="System.UInt32"/> specifying the key that will
/// be bound (see the Gdk.Key enumeration for common values).
/// </param>
/// <param name="modifiers">
/// The <see cref="Gdk.ModifierType"/> to be used on key
/// for this binding.
/// </param>
/// <param name="flags">
/// The <see cref="Gtk.AccelFlags"/> for this binding.
/// </param>
public void AddAccelerator(EventHandler handler,
uint key,
Gdk.ModifierType modifiers,
Gtk.AccelFlags flags)
{
Gtk.MenuItem foo = new Gtk.MenuItem ();
foo.Activated += handler;
foo.AddAccelerator ("activate",
accel_group,
key,
modifiers,
flags);
foo.Show ();
fake_menu.Append (foo);
}
示例8: OnPopulatePopup
void OnPopulatePopup (object sender, Gtk.PopulatePopupArgs args)
{
args.Menu.AccelGroup = accel_group;
Logger.Debug ("Populating context menu...");
// Remove the lame-o gigantic Insert Unicode Control
// Characters menu item.
Gtk.Widget lame_unicode;
lame_unicode = (Gtk.Widget)
args.Menu.Children [args.Menu.Children.Length - 1];
args.Menu.Remove (lame_unicode);
Gtk.MenuItem spacer1 = new Gtk.SeparatorMenuItem ();
spacer1.Show ();
Gtk.ImageMenuItem search = new Gtk.ImageMenuItem (
Catalog.GetString ("_Search All Notes"));
search.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu);
search.Activated += SearchActivate;
search.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.f,
(Gdk.ModifierType.ControlMask |
Gdk.ModifierType.ShiftMask),
Gtk.AccelFlags.Visible);
search.Show ();
Gtk.ImageMenuItem link =
new Gtk.ImageMenuItem (Catalog.GetString ("_Link to New Note"));
link.Image = new Gtk.Image (Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
link.Sensitive = (note.Buffer.Selection != null);
link.Activated += LinkToNoteActivate;
link.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.l,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
link.Show ();
Gtk.ImageMenuItem text_item =
new Gtk.ImageMenuItem (Catalog.GetString ("Te_xt"));
text_item.Image = new Gtk.Image (Gtk.Stock.SelectFont, Gtk.IconSize.Menu);
text_item.Submenu = new NoteTextMenu (accel_group,
note.Buffer,
note.Buffer.Undoer);
text_item.Show ();
Gtk.ImageMenuItem find_item =
new Gtk.ImageMenuItem (Catalog.GetString ("_Find in This Note"));
find_item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu);
find_item.Submenu = MakeFindMenu ();
find_item.Show ();
Gtk.MenuItem spacer2 = new Gtk.SeparatorMenuItem ();
spacer2.Show ();
args.Menu.Prepend (spacer1);
args.Menu.Prepend (text_item);
args.Menu.Prepend (find_item);
args.Menu.Prepend (link);
args.Menu.Prepend (search);
Gtk.MenuItem close_all =
new Gtk.MenuItem (Catalog.GetString ("Clos_e All Notes"));
close_all.Activated += CloseAllWindowsHandler;
close_all.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.q,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
close_all.Show ();
Gtk.ImageMenuItem close_window =
new Gtk.ImageMenuItem (Catalog.GetString ("_Close"));
close_window.Image = new Gtk.Image (Gtk.Stock.Close, Gtk.IconSize.Menu);
close_window.Activated += CloseWindowHandler;
close_window.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.w,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
close_window.Show ();
args.Menu.Append (close_all);
args.Menu.Append (close_window);
}
示例9: NoteTextMenu
// FIXME: Tags applied to a word should hold over the space
// between the next word, as thats where you'll start typeing.
// Tags are only active -after- a character with that tag. This
// is different from the way gtk-textbuffer applies tags.
//
// Text menu
//
// Menu for font style and size, and set the active radio
// menuitem depending on the cursor poition.
//
public NoteTextMenu (Gtk.AccelGroup accel_group,
NoteBuffer buffer,
UndoManager undo_manager)
: base ()
{
this.buffer = buffer;
this.undo_manager = undo_manager;
if (undo_manager != null) {
undo = new Gtk.ImageMenuItem (Gtk.Stock.Undo, accel_group);
undo.Activated += UndoClicked;
undo.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.z,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
undo.Show ();
Append (undo);
redo = new Gtk.ImageMenuItem (Gtk.Stock.Redo, accel_group);
redo.Activated += RedoClicked;
redo.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.z,
(Gdk.ModifierType.ControlMask |
Gdk.ModifierType.ShiftMask),
Gtk.AccelFlags.Visible);
redo.Show ();
Append (redo);
Gtk.SeparatorMenuItem undo_spacer = new Gtk.SeparatorMenuItem ();
Append (undo_spacer);
// Listen to events so we can sensitize and
// enable keybinding
undo_manager.UndoChanged += UndoChanged;
}
bold = new Gtk.CheckMenuItem ("<b>" +
Catalog.GetString ("_Bold") +
"</b>");
MarkupLabel (bold);
bold.Data ["Tag"] = "bold";
bold.Activated += FontStyleClicked;
bold.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.b,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
italic = new Gtk.CheckMenuItem ("<i>" +
Catalog.GetString ("_Italic") +
"</i>");
MarkupLabel (italic);
italic.Data ["Tag"] = "italic";
italic.Activated += FontStyleClicked;
italic.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.i,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
strikeout = new Gtk.CheckMenuItem ("<s>" +
Catalog.GetString ("_Strikeout") +
"</s>");
MarkupLabel (strikeout);
strikeout.Data ["Tag"] = "strikethrough";
strikeout.Activated += FontStyleClicked;
strikeout.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.s,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
highlight = new Gtk.CheckMenuItem ("<span background='yellow'>" +
Catalog.GetString ("_Highlight") +
"</span>");
MarkupLabel (highlight);
highlight.Data ["Tag"] = "highlight";
highlight.Activated += FontStyleClicked;
highlight.AddAccelerator ("activate",
accel_group,
(uint) Gdk.Key.h,
Gdk.ModifierType.ControlMask,
Gtk.AccelFlags.Visible);
Gtk.SeparatorMenuItem spacer1 = new Gtk.SeparatorMenuItem ();
//.........这里部分代码省略.........