protected override void Initialize(IPadWindow container) { base.Initialize(container); #if MAC toolbox = new Toolbox.MacToolbox(DesignerSupport.Service.ToolboxService, container); widget = GtkMacInterop.NSViewToGtkWidget(toolbox); widget.CanFocus = true; widget.Sensitive = true; widget.KeyPressEvent += toolbox.OnKeyPressed; widget.KeyReleaseEvent += toolbox.KeyReleased; widget.DragBegin += (o, args) => { if (!isDragging) { DesignerSupport.Service.ToolboxService.DragSelectedItem(widget, args.Context); isDragging = true; } }; widget.DragEnd += (o, args) => { isDragging = false; }; widget.Focused += (s, e) => { toolbox.FocusSelectedView(); }; toolbox.ContentFocused += (s, e) => { if (!widget.HasFocus) { widget.HasFocus = true; toolbox.FocusSelectedView(); } }; toolbox.DragSourceSet += (s, e) => { targets = new Gtk.TargetList(); targets.AddTable(e); }; toolbox.DragBegin += (object sender, EventArgs e) => { if (!isDragging) { Gtk.Drag.SourceUnset(widget); // Gtk.Application.CurrentEvent and other copied gdk_events seem to have a problem // when used as they use gdk_event_copy which seems to crash on de-allocating the private slice. IntPtr currentEvent = GtkWorkarounds.GetCurrentEventHandle(); Gtk.Drag.Begin(widget, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move, 1, new Gdk.Event(currentEvent)); // gtk_drag_begin does not store the event, so we're okay GtkWorkarounds.FreeEvent(currentEvent); } }; widget.ShowAll(); #else widget = new Toolbox.Toolbox(DesignerSupport.Service.ToolboxService, container); #endif }
void Widget_Focused(object sender, EventArgs args) { toolbox.FocusSelectedView(); }