示例#1
0
            public virtual EventFilter_FilterAction AcceptEvent(AWTEvent @event)
            {
                if (ModalComponent != null)
                {
                    int  eventID            = @event.ID;
                    bool mouseEvent         = (eventID >= MouseEvent.MOUSE_FIRST) && (eventID <= MouseEvent.MOUSE_LAST);
                    bool actionEvent        = (eventID >= ActionEvent.ACTION_FIRST) && (eventID <= ActionEvent.ACTION_LAST);
                    bool windowClosingEvent = (eventID == WindowEvent.WINDOW_CLOSING);

                    /*
                     * filter out MouseEvent and ActionEvent that's outside
                     * the modalComponent hierarchy.
                     * KeyEvent is handled by using enqueueKeyEvent
                     * in Dialog.show
                     */
                    if (Component.IsInstanceOf(ModalComponent, "javax.swing.JInternalFrame"))
                    {
                        /*
                         * Modal internal frames are handled separately. If event is
                         * for some component from another heavyweight than modalComp,
                         * it is accepted. If heavyweight is the same - we still accept
                         * event and perform further filtering in LightweightDispatcher
                         */
                        return(windowClosingEvent ? EventFilter_FilterAction.REJECT : EventFilter_FilterAction.ACCEPT);
                    }
                    if (mouseEvent || actionEvent || windowClosingEvent)
                    {
                        Object o = @event.Source;
                        if (o is sun.awt.ModalExclude)
                        {
                            // Exclude this object from modality and
                            // continue to pump it's events.
                            return(EventFilter_FilterAction.ACCEPT);
                        }
                        else if (o is Component)
                        {
                            Component c = (Component)o;
                            // 5.0u3 modal exclusion
                            bool modalExcluded = false;
                            if (ModalComponent is Container)
                            {
                                while (c != ModalComponent && c != null)
                                {
                                    if ((c is Window) && (sun.awt.SunToolkit.isModalExcluded((Window)c)))
                                    {
                                        // Exclude this window and all its children from
                                        //  modality and continue to pump it's events.
                                        modalExcluded = true;
                                        break;
                                    }
                                    c = c.Parent;
                                }
                            }
                            if (!modalExcluded && (c != ModalComponent))
                            {
                                return(EventFilter_FilterAction.REJECT);
                            }
                        }
                    }
                }
                return(EventFilter_FilterAction.ACCEPT);
            }