Ejemplo n.º 1
0
        public Control()
        {
            pBox=	new Box(Point.ORIGIN, Size.NO_SIZE);
            pParent=	null;
            children=	new List<Control>();
            oldMouse=	new MouseState();
            bHover=	false;
            click=	0;
            pVisible=	true;
            pEnabled=	true;
            pBackColors=	ColorPacket.DEFAULT;

            eonRelocate=	null;
            eonResize=	null;
            eonParentChanged=	null;
            eonBoxChanged=	null;
            eonWindowResize=	null;
            eonGuiAdded=	null;
            eonMouseEnter=	null;
            eonMouseLeave=	null;
            eonMouseClick=	null;
            eonMouseHover=	null;
            eonKeyPress=	null;
            eonEnabledChanged=	null;
            eonVisibleChanged=	null;
            eonGuiOpen=	null;
            eonGuiClose=	null;
        }
Ejemplo n.º 2
0
        // Handles the input of the component
        public virtual void handleInput(ref InputArgs args)
        {
            if(!pVisible)
                return;

            // Variables
            bool	bBounds=	pBox.contains(args.mouse.position);

            if(click!= 0)
            {
                if((click&1)!= 0 && args.isKeyUp(MBL.LMB))
                    click-=	1;
                if((click&2)!= 0 && args.isKeyUp(MBL.MMB))
                    click-=	2;
                if((click&4)!= 0 && args.isKeyUp(MBL.RMB))
                    click-=	4;
                if((click&8)!= 0 && args.isKeyUp(MBL.XB1))
                    click-=	8;
                if((click&16)!= 0 && args.isKeyUp(MBL.XB2))
                    click-=	16;
                if(click== 0)
                {
                    if(eonMouseClick!= null)
                        eonMouseClick(this, oldMouse);
                }
            }
            if(pEnabled && !bHover && bBounds)
            {
                bHover=	true;
                if(eonMouseEnter!= null)
                    eonMouseEnter(this, args.mouse);
            }
            if(pEnabled && bHover && bBounds)
            {
                if(eonMouseHover!= null)
                    eonMouseHover(this, args.mouse);
                if(click== 0)
                {
                    if(args.isKeyDown(MBL.LMB))	click+=	1;
                    if(args.isKeyDown(MBL.MMB))	click+=	2;
                    if(args.isKeyDown(MBL.RMB))	click+=	4;
                    if(args.isKeyDown(MBL.XB1))	click+=	8;
                    if(args.isKeyDown(MBL.XB2))	click+=	16;
                    oldMouse=	args.mouse;
                }
            }
            if(pEnabled && bHover && !bBounds)
            {
                bHover=	false;
                if(eonMouseLeave!= null)
                    eonMouseLeave(this, args.mouse);
            }

            for(int i= 0; i< children.size; i++)
                children.items[i].handleInput(ref args);
            if(eonKeyPress!= null && args.isKeyDown(KKL.ANY))
                eonKeyPress(this, args.keyboard);
        }