Example #1
0
        static bool KeyEvent(BubbleEventArgs be, Action <Control, Control.ICallback, KeyEventArgs> action, KeyEventType keyEventType)
        {
            Keys keyData = ((swf.Keys)(long) be.Message.WParam | swf.Control.ModifierKeys).ToEto();

            char?keyChar = null;
            var  kevt    = new KeyEventArgs(keyData, keyEventType, keyChar);

            if (be.Control != null)
            {
                action(be.Control, (Control.ICallback)((ICallbackSource)be.Control).Callback, kevt);
            }
            if (!kevt.Handled && (keyEventType != KeyEventType.KeyDown || !IsInputKey(be.Message.HWnd, keyData)))
            {
                foreach (var control in be.Parents)
                {
                    var callback = (Control.ICallback)((ICallbackSource)control).Callback;
                    action(control, callback, kevt);
                    if (kevt.Handled)
                    {
                        break;
                    }
                }
            }
            return(kevt.Handled);
        }
Example #2
0
        public bool PreFilterMessage(ref swf.Message message)
        {
            BubbleEvent bubble;

            if (messages.TryGetValue(message.Msg, out bubble))
            {
                var child = swf.Control.FromHandle(message.HWnd);

                if (child != null)
                {
                    var args = new BubbleEventArgs(message, child);
                    if (bubble.HandleEvent(args))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #3
0
        static bool MouseEvent(BubbleEventArgs be, Action <Control, Control.ICallback, MouseEventArgs> action, bool?capture, Func <MouseButtons, MouseButtons> modifyButtons = null)
        {
            var mainControl = be.Control;

            if (mainControl == null)
            {
                return(false);
            }

            var modifiers = swf.Control.ModifierKeys.ToEto();
            var delta     = new SizeF(0, Win32.GetWheelDeltaWParam(be.Message.WParam) / WinConversions.WheelDelta);
            var buttons   = Win32.GetMouseButtonWParam(be.Message.WParam).ToEto();

            if (modifyButtons != null)
            {
                buttons = modifyButtons(buttons);
            }
            var handler       = be.WindowsControl;
            var mousePosition = swf.Control.MousePosition.ToEto();

            var msg = be.Message;
            var me  = new MouseEventArgs(buttons, modifiers, mainControl.PointFromScreen(mousePosition), delta);

            action(mainControl, handler.Callback, me);

            if (!me.Handled && handler != null && handler.ShouldBubbleEvent(msg))
            {
                foreach (var control in be.Parents)
                {
                    me = new MouseEventArgs(buttons, modifiers, control.PointFromScreen(mousePosition), delta);
                    action(control, handler.Callback, me);
                    if (me.Handled)
                    {
                        return(true);
                    }
                }
            }
            return(me.Handled);
        }
Example #4
0
        static bool KeyCharEvent(BubbleEventArgs be, Action <Control, Control.ICallback, KeyEventArgs> action, KeyEventType keyEventType)
        {
            char keyChar = (char)((long)be.Message.WParam);
            var  kevt    = new KeyEventArgs(Keys.None, keyEventType, keyChar);

            if (be.Control != null)
            {
                action(be.Control, (Control.ICallback)((ICallbackSource)be.Control).Callback, kevt);
            }
            if (!kevt.Handled && !IsInputChar(be.Message.HWnd, keyChar))
            {
                foreach (var control in be.Parents)
                {
                    var callback = (Control.ICallback)((ICallbackSource)control).Callback;
                    action(control, callback, kevt);
                    if (kevt.Handled)
                    {
                        break;
                    }
                }
            }
            return(kevt.Handled);
        }
Example #5
0
		public bool PreFilterMessage(ref swf.Message message)
		{
			BubbleEvent bubble;
			if (messages.TryGetValue(message.Msg, out bubble))
			{
				var child = swf.Control.FromHandle(message.HWnd);

				if (child != null)
				{
					var args = new BubbleEventArgs(message, child);
					if (bubble.HandleEvent(args))
						return true;
				}
			}
			return false;
		}
Example #6
0
		static bool KeyCharEvent(BubbleEventArgs be, Action<Control, Control.ICallback, KeyEventArgs> action, KeyEventType keyEventType)
		{
			char keyChar = (char)((long)be.Message.WParam);
			var kevt = new KeyEventArgs(Keys.None, keyEventType, keyChar);
			if (be.Control != null)
				action(be.Control, (Control.ICallback)((ICallbackSource)be.Control).Callback, kevt);
			if (!kevt.Handled && !IsInputChar(be.Message.HWnd, keyChar))
			{
				foreach (var control in be.Parents)
				{
					var callback = (Control.ICallback)((ICallbackSource)control).Callback;
					action(control, callback, kevt);
					if (kevt.Handled)
						break;
				}
			}
			return kevt.Handled;
		}
Example #7
0
		static bool KeyEvent(BubbleEventArgs be, Action<Control, Control.ICallback, KeyEventArgs> action, KeyEventType keyEventType)
		{
			Keys keyData = ((swf.Keys)(long)be.Message.WParam | swf.Control.ModifierKeys).ToEto();
			
			char? keyChar = null;
			var kevt = new KeyEventArgs(keyData, keyEventType, keyChar);
			if (be.Control != null)
				action(be.Control, (Control.ICallback)((ICallbackSource)be.Control).Callback, kevt);
			if (!kevt.Handled && (keyEventType != KeyEventType.KeyDown || !IsInputKey(be.Message.HWnd, keyData)))
			{
				foreach (var control in be.Parents)
				{
					var callback = (Control.ICallback)((ICallbackSource)control).Callback;
					action(control, callback, kevt);
					if (kevt.Handled)
						break;
				}
			}
			return kevt.Handled;
		}
Example #8
0
		static bool MouseEvent(BubbleEventArgs be, Action<Control, Control.ICallback, MouseEventArgs> action, bool? capture, Func<MouseButtons, MouseButtons> modifyButtons = null)
		{
			var mainControl = be.Control;
			if (mainControl == null)
				return false;

			var modifiers = swf.Control.ModifierKeys.ToEto();
			var delta = new SizeF(0, Win32.GetWheelDeltaWParam(be.Message.WParam) / WinConversions.WheelDelta);
			var buttons = Win32.GetMouseButtonWParam(be.Message.WParam).ToEto();
			if (modifyButtons != null)
				buttons = modifyButtons(buttons);
			var handler = be.WindowsControl;
			var mousePosition = swf.Control.MousePosition.ToEto();

			var msg = be.Message;
			var me = new MouseEventArgs(buttons, modifiers, mainControl.PointFromScreen(mousePosition), delta);
			action(mainControl, handler.Callback, me);

			if (!me.Handled && handler != null && handler.ShouldBubbleEvent(msg))
			{
				foreach (var control in be.Parents)
				{
					me = new MouseEventArgs(buttons, modifiers, control.PointFromScreen(mousePosition), delta);
					action(control, handler.Callback, me);
					if (me.Handled)
						return true;
				}
			}
			return me.Handled;
		}