Example #1
0
 void EnableLinkEvents()
 {
     if (!linkEventEnabled)
     {
         linkEventEnabled = true;
         AllocEventBox();
         EventsRootWidget.AddEvents((int)Gdk.EventMask.PointerMotionMask);
         EventsRootWidget.MotionNotifyEvent += HandleMotionNotifyEvent;
         EventsRootWidget.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
         EventsRootWidget.ButtonReleaseEvent += HandleButtonReleaseEvent;
         EventsRootWidget.AddEvents((int)Gdk.EventMask.LeaveNotifyMask);
         EventsRootWidget.LeaveNotifyEvent += HandleLeaveNotifyEvent;
     }
 }
Example #2
0
 void SubscribeCursorEnterLeaveEvent()
 {
     if (!cursorEnterLeaveSubscribed)
     {
         cursorEnterLeaveSubscribed = true;                 // subscribe only once
         EventsRootWidget.AddEvents((int)Gdk.EventMask.EnterNotifyMask);
         EventsRootWidget.AddEvents((int)Gdk.EventMask.LeaveNotifyMask);
         EventsRootWidget.EnterNotifyEvent += (o, args) => {
             immediateCursorChange = true;
             if (gdkCursor != null)
             {
                 ((Gtk.Widget)o).GdkWindow.Cursor = gdkCursor;
             }
         };
         EventsRootWidget.LeaveNotifyEvent += (o, args) => {
             immediateCursorChange            = false;
             ((Gtk.Widget)o).GdkWindow.Cursor = null;
         };
     }
 }
Example #3
0
        public virtual void EnableEvent(object eventId)
        {
            if (eventId is WidgetEvent)
            {
                WidgetEvent ev = (WidgetEvent)eventId;
                switch (ev)
                {
                case WidgetEvent.DragLeave:
                    AllocEventBox();
                    EventsRootWidget.DragLeave += HandleWidgetDragLeave;
                    break;

                case WidgetEvent.DragStarted:
                    AllocEventBox();
                    EventsRootWidget.DragBegin += HandleWidgetDragBegin;
                    break;

                case WidgetEvent.KeyPressed:
                    Widget.KeyPressEvent += HandleKeyPressEvent;
                    break;

                case WidgetEvent.KeyReleased:
                    Widget.KeyReleaseEvent += HandleKeyReleaseEvent;
                    break;

                case WidgetEvent.GotFocus:
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.FocusChangeMask);
                    Widget.FocusGrabbed += HandleWidgetFocusInEvent;
                    break;

                case WidgetEvent.LostFocus:
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.FocusChangeMask);
                    Widget.FocusOutEvent += HandleWidgetFocusOutEvent;
                    break;

                case WidgetEvent.MouseEntered:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.EnterNotifyMask);
                    EventsRootWidget.EnterNotifyEvent += HandleEnterNotifyEvent;
                    break;

                case WidgetEvent.MouseExited:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.LeaveNotifyMask);
                    EventsRootWidget.LeaveNotifyEvent += HandleLeaveNotifyEvent;
                    break;

                case WidgetEvent.ButtonPressed:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.ButtonPressMask);
                    EventsRootWidget.ButtonPressEvent += HandleButtonPressEvent;
                    break;

                case WidgetEvent.ButtonReleased:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.ButtonReleaseMask);
                    EventsRootWidget.ButtonReleaseEvent += HandleButtonReleaseEvent;
                    break;

                case WidgetEvent.MouseMoved:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.PointerMotionMask);
                    EventsRootWidget.MotionNotifyEvent += HandleMotionNotifyEvent;
                    break;

                case WidgetEvent.BoundsChanged:
                    Widget.SizeAllocated += HandleWidgetBoundsChanged;
                    break;

                case WidgetEvent.MouseScrolled:
                    AllocEventBox();
                    EventsRootWidget.AddEvents((int)Gdk.EventMask.ScrollMask);
                    Widget.ScrollEvent += HandleScrollEvent;
                    break;
                }
                if ((ev & dragDropEvents) != 0 && (enabledEvents & dragDropEvents) == 0)
                {
                    // Enabling a drag&drop event for the first time
                    AllocEventBox();
                    EventsRootWidget.DragDrop         += HandleWidgetDragDrop;
                    EventsRootWidget.DragMotion       += HandleWidgetDragMotion;
                    EventsRootWidget.DragDataReceived += HandleWidgetDragDataReceived;
                }
                if ((ev & WidgetEvent.PreferredSizeCheck) != 0)
                {
                    EnableSizeCheckEvents();
                }
                enabledEvents |= ev;
            }
        }