예제 #1
0
        AABB buttonBounds;         //it is easy to store button bounds as an AABB

        public Button(TextureName image, float width, float height, Vector2 position, float scale, Scene scene, OnMouseHover mouseHoverEvent = null, OnMouseEnter mouseEnterEvent = null, OnMouseLeave mouseLeaveEvent = null) : base(image, position, scale, 0, null, true)
        {
            buttonBounds = new AABB(new Vector2(width / 2, height / 2), width, height);
            if (scene != null)
            {
                scene.AddUIElement(this);
            }

            if (mouseHoverEvent == null)
            {
                mH += DefaultHoverEvent;
            }
            else
            {
                mH += mouseHoverEvent;
            }

            if (mouseLeaveEvent == null)
            {
                mL += DefaultExitEvent;
            }
            else
            {
                mL += mouseLeaveEvent;
            }

            if (mouseEnterEvent == null)
            {
                mE += DefaultEnterEvent;
            }
            else
            {
                mE += mouseEnterEvent;
            }
        }
예제 #2
0
 public override void resetProperty()
 {
     base.resetProperty();
     // 重置所有成员变量
     mObjectID            = -1;
     mPhysicsAcceleration = Vector3.zero;
     mLastPhysicsSpeed    = Vector3.zero;
     mPhysicsSpeed        = Vector3.zero;
     mLastPhysicsPosition = Vector3.zero;
     mCurFramePosition    = Vector3.zero;
     mLastPosition        = Vector3.zero;
     mMouseDownPosition   = Vector3.zero;
     mLastSpeed           = Vector3.zero;
     mMoveSpeed           = Vector3.zero;
     mObject           = null;
     mTransform        = null;
     mAudioSource      = null;
     mOnMouseEnter     = null;
     mOnMouseLeave     = null;
     mOnMouseDown      = null;
     mOnMouseUp        = null;
     mOnMouseMove      = null;
     mClickCallback    = null;
     mHoverCallback    = null;
     mPressCallback    = null;
     mMovedDuringFrame = false;
     mHasLastPosition  = false;
     mDestroyObject    = true;
     mDestroied        = false;
     mMouseHovered     = false;
     mHandleInput      = true;
     mPassRay          = false;
 }
예제 #3
0
        public virtual void Update(GameTime gameTime)
        {
            MouseState state = Mouse.GetState();

            if (position.Intersects(new Rectangle(state.Position, new Point(15, 15))))
            {
                hovered = true;
                OnMouseEnter?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                if (hovered)
                {
                    OnMouseLeave?.Invoke(this, EventArgs.Empty);
                    hovered = false;
                }
            }

            if (hovered && state.LeftButton == ButtonState.Released && prevState.LeftButton == ButtonState.Pressed)
            {
                OnMouseLeftClicked?.Invoke(this, EventArgs.Empty);
            }
            else if (hovered && state.RightButton == ButtonState.Released && prevState.RightButton == ButtonState.Pressed)
            {
                OnMouseRightClicked?.Invoke(this, EventArgs.Empty);
            }
            else if (isSelected && Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                OnEnter?.Invoke(this, EventArgs.Empty);
            }

            prevState = state;
        }
예제 #4
0
 protected void OnLeave(ButtonEventArgs e)
 {
     if (prevMS != null)
     {
         if (!new Rectangle(e.ms.X, e.ms.Y, 1, 1).Intersects(HitBox) && new Rectangle(prevMS.X, prevMS.Y, 1, 1).Intersects(HitBox))
         {
             OnMouseLeave?.Invoke(this, e);
         }
     }
 }
예제 #5
0
        private void HandleUnitWaiting()
        {
            if (InputManager.HasEntered(LocationRectangle))
            {
                OnMouseEnter?.Invoke(this, EventArgs.Empty);
            }

            if (InputManager.HasLeaved(LocationRectangle))
            {
                OnMouseLeave?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #6
0
        public NotifyIconMouseEvent(NotifyIcon ni, OnMouseEnter enter, OnMouseLeave leave)
        {
            m_OnMouseEnter = enter;
            m_OnMouseLeave = leave;

            m_niTray      = ni;
            ni.MouseMove += new MouseEventHandler(ni_MouseMove);

            m_tmrMouseTracer          = new Timer();
            m_tmrMouseTracer.Interval = 100;
            m_tmrMouseTracer.Tick    += new EventHandler(m_tmrMouseTracer_Tick);
        }
예제 #7
0
        protected virtual async Task OnTriggerMouseLeave()
        {
            _mouseInTrigger = false;

            if (_overlay != null && IsContainTrigger(TriggerType.Hover))
            {
                _overlay.PreventHide(_mouseInOverlay);

                await Hide();
            }

            OnMouseLeave?.Invoke();
        }
예제 #8
0
 public void setOnMouseLeave(OnMouseLeave callback)
 {
     mOnMouseLeave = callback;
 }
예제 #9
0
 protected virtual Task HandleMouseLeave(EventArgs args)
 {
     return(OnMouseLeave.InvokeAsync(args));
 }
 public void OnPointerExit(PointerEventData eventData)
 {
     OnMouseLeave?.Invoke();
 }
        internal void DispatchEvent(Map map, MapJsEventArgs eventArgs)
        {
            switch (eventArgs.Type)
            {
            case "click":
                OnClick?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "contextmenu":
                OnContextMenu?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "dblclick":
                OnDblClick?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "layeradded":
                OnLayerAdded?.Invoke(new MapEventArgs(map, eventArgs.Type));
                break;

            case "layerremoved":
                OnLayerRemoved?.Invoke(new MapEventArgs(map, eventArgs.Type));
                break;

            case "mousedown":
                OnMouseDown?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mouseenter":
                OnMouseEnter?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mouseleave":
                OnMouseLeave?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mousemove":
                OnMouseMove?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mouseout":
                OnMouseOut?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mouseover":
                OnMouseOver?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "mouseup":
                OnMouseUp?.Invoke(new MapMouseEventArgs(map, eventArgs));
                break;

            case "touchcancel":
                OnTouchCancel?.Invoke(new MapTouchEventArgs(map, eventArgs));
                break;

            case "touchend":
                OnTouchEnd?.Invoke(new MapTouchEventArgs(map, eventArgs));
                break;

            case "touchmove":
                OnTouchMove?.Invoke(new MapTouchEventArgs(map, eventArgs));
                break;

            case "touchstart":
                OnTouchStart?.Invoke(new MapTouchEventArgs(map, eventArgs));
                break;

            case "wheel":
                OnWheel?.Invoke(new MapEventArgs(map, eventArgs.Type));
                break;
            }
        }
예제 #12
0
        /// <summary> Adds the events for this html element directly to the text writer output </summary>
        /// <param name="Output"> Output to write directly to </param>
        public void Add_Events_HTML(TextWriter Output)
        {
            if (!String.IsNullOrWhiteSpace(OnClick))
            {
                Output.Write("onclick=\"" + OnClick.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnContextMenu))
            {
                Output.Write("oncontextmenu=\"" + OnContextMenu.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnDblClick))
            {
                Output.Write("ondblclick=\"" + OnDblClick.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseDown))
            {
                Output.Write("onmousedown=\"" + OnMouseDown.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseEnter))
            {
                Output.Write("onmouseenter=\"" + OnMouseEnter.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseLeave))
            {
                Output.Write("onmouseleave=\"" + OnMouseLeave.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseMove))
            {
                Output.Write("onmousemove=\"" + OnMouseMove.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseOver))
            {
                Output.Write("onmouseover=\"" + OnMouseOver.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseOut))
            {
                Output.Write("onmouseout=\"" + OnMouseOut.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnMouseUp))
            {
                Output.Write("onmouseup=\"" + OnMouseUp.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnKeyDown))
            {
                Output.Write("onkeydown=\"" + OnKeyDown.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnKeyPress))
            {
                Output.Write("onkeypress=\"" + OnKeyPress.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnKeyUp))
            {
                Output.Write("onkeyup=\"" + OnKeyUp.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnLoad))
            {
                Output.Write("onload=\"" + OnLoad.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnSelect))
            {
                Output.Write("onselect=\"" + OnSelect.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnChange))
            {
                Output.Write("onchange=\"" + OnChange.Replace("\"", "'") + "\" ");
            }

            if (!String.IsNullOrWhiteSpace(OnWheel))
            {
                Output.Write("onwheel=\"" + OnWheel.Replace("\"", "'") + "\" ");
            }
        }
예제 #13
0
        public override void PollEvents()
        {
            while (SDL_PollEvent(out var ev) == 1)
            {
                switch (ev.type)
                {
                case SDL_EventType.SDL_QUIT:
                    OnQuit?.Invoke();
                    break;

                case SDL_EventType.SDL_KEYDOWN:
                    AddKey((int)ev.key.keysym.sym);
                    break;

                case SDL_EventType.SDL_KEYUP:
                    RemoveKey((int)ev.key.keysym.sym);
                    break;

                case SDL_EventType.SDL_TEXTINPUT:

                    break;

                case SDL_EventType.SDL_MOUSEBUTTONDOWN:
                    SetMouseButtonState(ev.button.button, true);
                    break;

                case SDL_EventType.SDL_MOUSEBUTTONUP:
                    SetMouseButtonState(ev.button.button, false);
                    break;

                case SDL_EventType.SDL_MOUSEWHEEL:
                    TriggerMouseScroll(ev.wheel.y * 120);
                    break;

                case SDL_EventType.SDL_CONTROLLERDEVICEADDED:

                    ProcessGamepadAdd(ev.cdevice.which);

                    break;

                case SDL_EventType.SDL_CONTROLLERDEVICEREMOVED:

                    ProcessGamepadRemove(ev.cdevice.which);

                    break;

                case SDL_EventType.SDL_WINDOWEVENT:
                    switch (ev.window.windowEvent)
                    {
                    case SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                        OnQuit?.Invoke();
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:

                        var w = ev.window.data1;
                        var h = ev.window.data2;

                        if (screen_w != w || screen_h != h)
                        {
                        }

                        screen_w = w;
                        screen_h = h;

                        OnWinResized?.Invoke(w, h);
                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:

                        OnMouseOver?.Invoke();

                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:

                        OnMouseLeave?.Invoke();

                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:

                        is_active = false;

                        break;

                    case SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:

                        is_active = true;

                        break;
                    }

                    break;
                }
            }
        }
        internal void DispatchEvent(Map map, HtmlMarkerJsEventArgs eventArgs)
        {
            if (eventArgs.Options != null)
            {
                var popupOptions = Options.Popup;
                Options       = eventArgs.Options;
                Options.Popup = popupOptions;
            }

            switch (eventArgs.Type)
            {
            case "click":
                OnClick?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "contextmenu":
                OnContextMenu?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "dblclick":
                OnDblClick?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "drag":
                OnDrag?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "dragend":
                OnDragEnd?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "dragstart":
                OnDragStart?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "keydown":
                OnKeyDown?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "keypress":
                OnKeyPress?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "keyup":
                OnKeyUp?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mousedown":
                OnMouseDown?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mouseenter":
                OnMouseEnter?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mouseleave":
                OnMouseLeave?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mousemove":
                OnMouseMove?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mouseout":
                OnMouseOut?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mouseover":
                OnMouseOver?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;

            case "mouseup":
                OnMouseUp?.Invoke(new HtmlMarkerEventArgs(map, eventArgs.Type, this));
                break;
            }
        }
예제 #15
0
 internal void TriggerOnMouseLeave(MouseState state)
 {
     OnMouseLeave?.Invoke(state);
 }
예제 #16
0
        public override async Task EventCallback(string eventName, string eventJson)
        {
            var jsonOptions = new JsonSerializerOptions {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            switch (eventName)
            {
            case "OnDidCompositionEnd":
                await OnDidCompositionEnd.InvokeAsync(this);

                break;

            case "OnDidCompositionStart":
                await OnDidCompositionStart.InvokeAsync(this);

                break;

            case "OnContextMenu":
                if (eventJson != null)
                {
                    await OnContextMenu.InvokeAsync(
                        JsonSerializer.Deserialize <EditorMouseEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnDidBlurEditorText":
                await OnDidBlurEditorText.InvokeAsync(this);

                break;

            case "OnDidBlurEditorWidget":
                await OnDidBlurEditorWidget.InvokeAsync(this);

                break;

            case "OnDidChangeConfiguration":
                await OnDidChangeConfiguration.InvokeAsync(this);

                break;

            case "OnDidChangeCursorPosition":
                await OnDidChangeCursorPosition.InvokeAsync(
                    JsonSerializer.Deserialize <CursorPositionChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeCursorSelection":
                await OnDidChangeCursorSelection.InvokeAsync(
                    JsonSerializer.Deserialize <CursorSelectionChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModel":
                await OnDidChangeModel.InvokeAsync(
                    JsonSerializer.Deserialize <ModelChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModelContent":
                await OnDidChangeModelContent.InvokeAsync(
                    JsonSerializer.Deserialize <ModelContentChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModelDecorations":
                await OnDidChangeModelDecorations.InvokeAsync(
                    JsonSerializer.Deserialize <ModelDecorationsChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModelLanguage":
                await OnDidChangeModelLanguage.InvokeAsync(
                    JsonSerializer.Deserialize <ModelLanguageChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModelLanguageConfiguration":
                await OnDidChangeModelLanguageConfiguration.InvokeAsync(
                    JsonSerializer.Deserialize <ModelLanguageConfigurationChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidChangeModelOptions":
                await OnDidChangeModelOptions.InvokeAsync(
                    JsonSerializer.Deserialize <ModelOptionsChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidContentSizeChange":
                await OnDidContentSizeChange.InvokeAsync(
                    JsonSerializer.Deserialize <ContentSizeChangedEvent>(eventJson, jsonOptions));

                break;

            case "OnDidFocusEditorText":
                await OnDidFocusEditorText.InvokeAsync(this);

                break;

            case "OnDidFocusEditorWidget":
                await OnDidFocusEditorWidget.InvokeAsync(this);

                break;

            case "OnDidLayoutChange":
                if (eventJson != null)
                {
                    await OnDidLayoutChange.InvokeAsync(
                        JsonSerializer.Deserialize <EditorLayoutInfo>(eventJson, jsonOptions));
                }
                break;

            case "OnDidPaste":
                if (eventJson != null)
                {
                    await OnDidPaste.InvokeAsync(JsonSerializer.Deserialize <PasteEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnDidScrollChange":
                if (eventJson != null)
                {
                    await OnDidScrollChange.InvokeAsync(
                        JsonSerializer.Deserialize <ScrollEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnKeyDown":
                if (eventJson != null)
                {
                    await OnKeyDown.InvokeAsync(JsonSerializer.Deserialize <KeyboardEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnKeyUp":
                if (eventJson != null)
                {
                    await OnKeyUp.InvokeAsync(JsonSerializer.Deserialize <KeyboardEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnMouseDown":
                if (eventJson != null)
                {
                    await OnMouseDown.InvokeAsync(
                        JsonSerializer.Deserialize <EditorMouseEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnMouseLeave":
                if (eventJson != null)
                {
                    await OnMouseLeave.InvokeAsync(
                        JsonSerializer.Deserialize <EditorMouseEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnMouseMove":
                if (eventJson != null)
                {
                    await OnMouseMove.InvokeAsync(
                        JsonSerializer.Deserialize <EditorMouseEvent>(eventJson, jsonOptions));
                }
                break;

            case "OnMouseUp":
                if (eventJson != null)
                {
                    await OnMouseUp.InvokeAsync(
                        JsonSerializer.Deserialize <EditorMouseEvent>(eventJson, jsonOptions));
                }
                break;
            }

            await base.EventCallback(eventName, eventJson);
        }
예제 #17
0
 public virtual void MouseLeave(MouseEventArgs e)
 {
     OnMouseLeave.SafeInvoke(this, TranslateMouseEventArgs(e));
 }
예제 #18
0
        /// <summary>
        /// Create the DropDown list.
        /// </summary>
        /// <param name="size">List size (refers to the whole size of the list + the header when dropdown list is opened).</param>
        /// <param name="anchor">Position anchor.</param>
        /// <param name="offset">Offset from anchor position.</param>
        /// <param name="skin">Panel skin to use for this DropDown list and header.</param>
        public DropDown(Vector2 size, Anchor anchor = Anchor.Auto, Vector2?offset = null, PanelSkin skin = PanelSkin.ListBackground) :
            base(size, anchor, offset)
        {
            // default padding of self is 0
            Padding = Vector2.Zero;

            // to get collision right when list is opened
            UseActualSizeForCollision = true;

            // create the panel and paragraph used to show currently selected value (what's shown when drop-down is closed)
            _selectedTextPanel     = new Panel(new Vector2(0, SelectedPanelHeight), skin, Anchor.TopLeft);
            _selectedTextParagraph = UserInterface.DefaultParagraph(string.Empty, Anchor.CenterLeft);
            _selectedTextParagraph.UseActualSizeForCollision = false;
            _selectedTextParagraph.UpdateStyle(SelectList.DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultSelectedParagraphStyle);
            _selectedTextPanel.AddChild(_selectedTextParagraph, true);

            // create the arrow down icon
            _arrowDownImage = new Image(Resources.ArrowDown, new Vector2(ArrowSize, ArrowSize), ImageDrawMode.Stretch, Anchor.CenterRight, new Vector2(-10, 0));
            _selectedTextPanel.AddChild(_arrowDownImage, true);

            // create the list component
            _selectList = new SelectList(size, Anchor.TopCenter, Vector2.Zero, skin);

            // update list offset and space before
            _selectList.SetOffset(new Vector2(0, SelectedPanelHeight));
            _selectList.SpaceBefore = Vector2.Zero;

            // add the header and select list as children
            AddChild(_selectedTextPanel);
            AddChild(_selectList);

            // add callback on list value change
            _selectList.OnValueChange = (Entity entity) =>
            {
                // hide list
                ListVisible = false;

                // set selected text
                _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);
            };

            // hide the list by default
            _selectList.Visible = false;

            // setup the callback to show / hide the list when clicking the dropbox
            _selectedTextPanel.OnClick = (Entity self) =>
            {
                // change visibility
                ListVisible = !ListVisible;
            };

            // set starting text
            _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);

            // update styles
            _selectList.UpdateStyle(DefaultStyle);

            // make the list events trigger the dropdown events
            _selectList.OnListChange       += (Entity entity) => { OnListChange?.Invoke(this); };
            _selectList.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectList.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectList.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectList.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectList.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectList.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectList.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectList.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectList.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectList.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectList.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectList.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectList.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectList.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectList.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectList.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };

            // make the selected value panel trigger the dropdown events
            _selectedTextPanel.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectedTextPanel.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectedTextPanel.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectedTextPanel.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectedTextPanel.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectedTextPanel.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectedTextPanel.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectedTextPanel.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectedTextPanel.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectedTextPanel.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectedTextPanel.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectedTextPanel.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectedTextPanel.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectedTextPanel.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectedTextPanel.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectedTextPanel.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };
        }
예제 #19
0
 public NotifyIconMouseEvent(NotifyIcon ni, OnMouseEnter enter, OnMouseLeave leave, object enterParam, object leaveParam)
     : this(ni, enter, leave)
 {
     m_oEnterParam = enterParam;
     m_oLeaveParam = leaveParam;
 }
예제 #20
0
 private void MouseLeft(object realEvent)
 {
     OnMouseLeave?.Invoke(new MouseLeaveEvent(this));
 }
예제 #21
0
        /// <summary>
        /// GUI部品を更新する。
        /// </summary>
        /// <param name="mouse">マウス。</param>
        /// <param name="pointX">マウスの相対X座標。</param>
        /// <param name="pointY">マウスの相対Y座標。</param>
        public virtual void Update(Mouse mouse = null, int?pointX = null, int?pointY = null)
        {
            if (mouse == null)
            {
                LeftJudge = (false, (0, 0));

                LongClickCounter.Stop();
                LongClickCounter.Reset();

                Dragging = false;
                return;
            }

            if (!pointX.HasValue || !pointY.HasValue)
            {
                MousePoint = (mouse.Point.x - X, mouse.Point.y - Y);
            }
            else
            {
                MousePoint = (pointX.Value - X, pointY.Value - Y);
            }

            var outSide = IsOutSide();

            if (!outSide)
            {
                OnHovering?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                if (!Hovering)
                {
                    OnMouseEnter?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                    Hovering = true;
                }
            }
            else
            {
                if (Hovering)
                {
                    OnMouseLeave?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                    Hovering = false;
                }
            }

            if (mouse.IsPushedButton(MouseButton.Left))
            {
                // マウス初回クリック処理
                if (!outSide)
                {
                    LeftJudge = (true, MousePoint);
                    LongClickCounter?.Start();
                    OnMouseDown?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                }
            }
            else if (mouse.IsPushingButton(MouseButton.Left))
            {
                // マウスが要素内をクリックしてるかどうかの判定
                if (LeftJudge.Item1)
                {
                    if (outSide)
                    {
                        LeftJudge = (false, MousePoint);
                        OnMouseUp?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                        LongClickCounter.Stop();
                        LongClickCounter.Reset();
                    }
                    else
                    {
                        LongClickCounter?.Tick();
                        if (LongClickCounter.State == TimerState.Stopped)
                        {
                            // ロングタップ
                            LeftJudge = (false, MousePoint);
                            OnMouseUp?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                            if (!Dragging)
                            {
                                LongClicked?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                            }
                            LongClickCounter.Stop();
                            LongClickCounter.Reset();

                            Dragging = false;
                        }
                    }
                }
            }
            else if (mouse.IsLeftButton(MouseButton.Left))
            {
                // クリック判定
                if (LeftJudge.Item1)
                {
                    if (!Dragging)
                    {
                        Clicked?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                    }
                    OnMouseUp?.Invoke(this, new MouseClickEventArgs(MousePoint.x, MousePoint.y));
                }
                LongClickCounter.Stop();
                LongClickCounter.Reset();

                Dragging = false;
            }

            foreach (var item in Child)
            {
                item.Update(mouse, MousePoint.x, MousePoint.y);
            }
        }
예제 #22
0
 private static void OnPlatformMouseLeave()
 {
     IsMouseOver = false;
     OnMouseLeave?.Invoke();
 }
예제 #23
0
 public void AddLeaveEvent(OnMouseLeave l)
 {
     mL += l;
 }