本文整理汇总了C#中Gtk.Window.GrabFocus方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GrabFocus方法的具体用法?C# Window.GrabFocus怎么用?C# Window.GrabFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Window
的用法示例。
在下文中一共展示了Window.GrabFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowCalendar
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;
}
示例2: ShowCalendar
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;
}
示例3: ShowPopup
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;
}
}