本文整理汇总了C#中eDriven.Core.Events.Event.CancelAndStopPropagation方法的典型用法代码示例。如果您正苦于以下问题:C# Event.CancelAndStopPropagation方法的具体用法?C# Event.CancelAndStopPropagation怎么用?C# Event.CancelAndStopPropagation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eDriven.Core.Events.Event
的用法示例。
在下文中一共展示了Event.CancelAndStopPropagation方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveAreaMouseDownHandler
private void MoveAreaMouseDownHandler(Event e)
{
//Debug.Log("Mouse down: " + e.Target);
//if (e.Target != MoveArea)
// return;
//Debug.Log("MoveAreaMouseDownHandler: " + e.Target);
// Only allow dragging of pop-upped windows
if (Enabled && IsPopUp)
{
e.CancelAndStopPropagation();
// Calculate the mouse's offset in the window
//offsetX = event.stageX - x;
//offsetY = event.stageY - y;
BringToFront();
MouseEvent me = (MouseEvent) e;
_offset = me.GlobalPosition.Subtract(Transform.Position);
var sm = SystemEventDispatcher.Instance;
sm.AddEventListener(MouseEvent.MOUSE_MOVE, MoveAreaMouseMoveHandler, EventPhase.CaptureAndTarget);
sm.AddEventListener(MouseEvent.MOUSE_UP, MoveAreaMouseUpHandler, EventPhase.CaptureAndTarget);
_cursorId = CursorManager.Instance.SetCursor(CursorType.Move);
}
}
示例2: KeyUpHandler
private void KeyUpHandler(Event e)
{
KeyboardEvent ke = (KeyboardEvent)e;
//Debug.Log("KeyUpHandler: " + ke.KeyCode);
if (KeyCode.Escape == ke.KeyCode)
{
//Debug.Log("DialogCloseOnEsc->Escape");
e.CancelAndStopPropagation();
//PopupManager.Instance.RemovePopup(_dialog);
if (Enabled)
_dialog.ExecCallback("cancel");
}
}
示例3: ThumbMouseDownHandler
/**
*
* Handle mouse-down events on the scroll thumb. Records
* the mouse down point in _clickOffset.
*/
protected virtual void ThumbMouseDownHandler(Event e)
{
e.CancelAndStopPropagation();
DragManager.IsDragging = true;
//Debug.Log("ThumbMouseDownHandler: " + e);
MouseEvent me = (MouseEvent) e;
var sm = SystemEventDispatcher.Instance;
sm.AddEventListener(MouseEvent.MOUSE_MOVE,
SystemMouseMoveHandler);
sm.AddEventListener(MouseEvent.MOUSE_UP,
SystemMouseUpHandler);
_clickOffset = Thumb.GlobalToLocal(me.GlobalPosition);
DispatchEvent(new TrackBaseEvent(TrackBaseEvent.THUMB_PRESS));
DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START));
}
示例4: MouseUpHandler
/// <summary>
/// Mouse up handler: unsubscribe from everything
/// </summary>
/// <param name="e"></param>
private void MouseUpHandler(Event e)
{
MouseEvent me = (MouseEvent) e;
e.CancelAndStopPropagation();
SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_MOVE, MouseMoveHandler, EventPhase.Capture | EventPhase.Target);
SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);
_component.IncludeInLayout = true;
IsResizing = false;
DragManager.IsDragging = false;
DeferManager.Instance.Defer(delegate
{
//Debug.Log("check");
//Point p = _component.GlobalToLocal(me.GlobalPosition);
DoRenderOverlay = IsMouseOverBorder(me.GlobalPosition);
if (DoRenderOverlay)
{
if (!_scanning)
ShowCursor();
}
else
{
if (_scanning)
HideCursor();
}
});
}
示例5: MouseMoveHandler
/// <summary>
/// Mouse move handler
/// Fires when in processing mode (resizing)
/// </summary>
/// <param name="e"></param>
private void MouseMoveHandler(Event e)
{
if (!IsResizing)
return;
e.CancelAndStopPropagation();
MouseEvent me = (MouseEvent)e;
Point position;
position = me.GlobalPosition;
var delta = position.Subtract(_clickCoords);
switch (_resizeMode)
{
case ResizeMode.Right:
_newBounds = _origBounds.Expand(0, delta.X, 0, 0);
break;
case ResizeMode.Left:
_newBounds = _origBounds.Expand(-delta.X, 0, 0, 0);
break;
case ResizeMode.Top:
_newBounds = _origBounds.Expand(0, 0, -delta.Y, 0);
break;
case ResizeMode.Bottom:
_newBounds = _origBounds.Expand(0, 0, 0, delta.Y);
break;
case ResizeMode.TopLeft:
_newBounds = _origBounds.Expand(-delta.X, 0, -delta.Y, 0);
break;
case ResizeMode.TopRight:
_newBounds = _origBounds.Expand(0, delta.X, -delta.Y, 0);
break;
case ResizeMode.BottomLeft:
_newBounds = _origBounds.Expand(-delta.X, 0, 0, delta.Y);
break;
case ResizeMode.BottomRight:
_newBounds = _origBounds.Expand(0, delta.X, 0, delta.Y);
break;
}
// gracefully handle the minimum sizes set by the user
_newBounds.X = Mathf.Min(_newBounds.X, _origBounds.Right - _component.MinWidth);
_newBounds.Y = Mathf.Min(_newBounds.Y, _origBounds.Bottom - _component.MinHeight);
_newBounds.Width = Mathf.Min(Mathf.Max(_newBounds.Width, _component.MinWidth), _component.MaxWidth); // MeasuredMinWidth
_newBounds.Height = Mathf.Min(Mathf.Max(_newBounds.Height, _component.MinHeight), _component.MaxHeight);
// apply
if (ChangeExplicitSize)
{
_component.Width = _newBounds.Width;
_component.Height = _newBounds.Height;
}
else
{
_component.SetActualSize(_newBounds.Width, _newBounds.Height);
}
_component.Move(_newBounds.X, _newBounds.Y);
/**
* When resizing by the top/left edge, the visual jitter can be observed in component's right-aligned children
* so to avoid this jitter, we should validate now
* */
if (_resizeMode == ResizeMode.Left ||
_resizeMode == ResizeMode.Top ||
_resizeMode == ResizeMode.TopLeft)
{
//_component.ValidateNow();
}
}
示例6: ClickHandler
/// <summary>
/// Click handler. Stop propagation if clicked on border.
/// </summary>
/// <param name="e"></param>
private void ClickHandler(Event e)
{
MouseEvent me = (MouseEvent)e;
if (IsMouseOverBorder(me.GlobalPosition))
e.CancelAndStopPropagation();
}
示例7: MouseDownHandler
/// <summary>
/// Mouse down handler
/// </summary>
/// <param name="e"></param>
private void MouseDownHandler(Event e)
{
//Debug.Log(string.Format("Resizable [{0}] -> MouseDownHandler", e.Target));
if (AutoBringToFront)
_component.BringToFront();
if (AutoExcludeFromLayout)
_component.IncludeInLayout = false;
MouseEvent me = (MouseEvent)e;
IsResizing = IsMouseOverBorder(me.GlobalPosition);
if (IsResizing)
{
e.CancelAndStopPropagation();
DoRenderOverlay = true;
_origBounds = _component.Bounds;
_clickCoords = me.GlobalPosition;
// subscribe to mouse moves
SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_MOVE, MouseMoveHandler, EventPhase.Capture | EventPhase.Target);
SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);
DragManager.IsDragging = true;
}
}
示例8: MouseUpHandler
private void MouseUpHandler(Event e)
{
e.CancelAndStopPropagation();
SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_MOVE, MouseMoveHandler);
SystemEventDispatcher.Instance.RemoveEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);
DoRenderOverlay = false;
DragManager.IsDragging = false;
if (-1 != _cursorId) {
CursorManager.Instance.RemoveCursor(_cursorId);
_cursorId = -1;
}
}
示例9: ComponentMouseDownHandler
private void ComponentMouseDownHandler(Event e)
{
Debug.Log(string.Format("ComponentMouseDownHandler [{0}, {1}]", e.Phase, e.CurrentTarget));
if (!Enabled)
return;
if (AutoBringToFront)
_component.BringToFront();
MouseEvent me = (MouseEvent) e;
//var container = _component.Parent as Container; // 20121125 (because dragging didn't work well when parent scrolled)
//_startCoordinates = null != container ?
// container.GlobalToContent(_component.Transform.GlobalPosition) : // GlobalToContent no more - TODO
// _component.Parent.GlobalToLocal(_component.Transform.GlobalPosition);
_clickCoordinates = me.GlobalPosition;
if (_constraintMode)
{
_constrainedRect = _constraintMetrics.GetConstrainedRectangle(_component.Transform.LocalBounds);
if (!_constrainedRect.Contains(me.LocalPosition))
return;
}
e.CancelAndStopPropagation();
DragManager.IsDragging = true;
SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_MOVE, MouseMoveHandler);
SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, MouseUpHandler);
if (-1 == _cursorId)
{
_cursorId = CursorManager.Instance.SetCursor(CursorType.Move, CursorPriority.High);
}
}
示例10: KeyDownHandler
private void KeyDownHandler(Event e)
{
KeyboardEvent ke = (KeyboardEvent)e;
int index = _components.IndexOf(FocusManager.Instance.FocusedComponent);
if (-1 == index)
return;
bool keyRecognized = false;
switch (ke.KeyCode)
{
case KeyCode.Tab:
//Debug.Log("Tab");
keyRecognized = true;
index = ke.Shift ? Previous(index, _circularTabs ?? false) : Next(index, _circularTabs ?? false);
break;
case KeyCode.LeftArrow:
//Debug.Log("LeftArrow");
if (_arrowsEnabled) {
keyRecognized = true;
index = Previous(index, _circularTabs ?? false);
}
break;
case KeyCode.RightArrow:
//Debug.Log("CircularArrows: " + CircularArrows);
if (_arrowsEnabled) {
keyRecognized = true;
index = Next(index, _circularTabs ?? false);
}
break;
case KeyCode.UpArrow:
//Debug.Log("LeftArrow");
if (_arrowsEnabled && _upDownArrowsEnabled) {
keyRecognized = true;
index = Previous(index, _circularTabs ?? false);
}
break;
case KeyCode.DownArrow:
//Debug.Log("CircularArrows: " + CircularArrows);
if (_arrowsEnabled && _upDownArrowsEnabled) {
keyRecognized = true;
index = Next(index, _circularTabs ?? false);
}
break;
default:
break;
}
if (keyRecognized)
{
/**
* Important: canceling the event alters with behavours of container children !!!
* (for instance, TabManager set on Form swallows the key events needed by combo box)
* */
e.CancelAndStopPropagation();
InteractiveComponent componentToFocus = _components[index] as InteractiveComponent;
if (null != componentToFocus) {
if (!componentToFocus.FocusEnabled)
{
#if DEBUG
if (DebugMode)
{
Debug.Log("Component is not focus enabled: " + componentToFocus);
return;
}
#endif
}
#if DEBUG
if (DebugMode)
{
Debug.Log("Focusing component: " + componentToFocus);
}
#endif
FocusManager.Instance.TabbedToFocus = true;
componentToFocus.SetFocus();
}
else
{
#if DEBUG
if (DebugMode)
{
Debug.LogWarning("Component to focus not instantiated");
}
#endif
}
}
}
示例11: ClickHandler
internal void ClickHandler(Event e)
{
//Debug.Log("GuiInspector->ClickHandler: " + e.Target);
#if DEBUG
if (DebugMode)
Debug.Log("GuiInspector->ClickHandler");
#endif
MouseEvent me = (MouseEvent)e;
if (me.CurrentEvent.control || me.CurrentEvent.shift)
{
//Debug.Log("Click");
if (Sticky)
{
// we are in sticky mode
if (e.Target == _currentComponent) // clicking the same component resets Sticky
Sticky = false;
else // else set new component as Sticky
_currentComponent = (Component)e.Target;
}
else // turn off sticky
Sticky = true;
_sticky = Sticky; // cancel off GUI changes
e.CancelAndStopPropagation(); // disable the actual button click in capture phase. Sweet ^_^
}
//_stack.Clear();
//ClickSignal.Emit(_currentComponent);
//Debug.Log("ClickSignal.NumSlots: " + ClickSignal.NumSlots);
}
示例12: SpecialClickHandler
internal void SpecialClickHandler(Event e)
{
#if DEBUG
if (DebugMode)
Debug.Log("DesignerOverlay->SpecialClickHandler: " + e.Target);
#endif
MouseEvent me = (MouseEvent)e;
if (me.CurrentEvent.control || me.CurrentEvent.shift)
{
e.CancelAndStopPropagation(); // disable the actual button click in the capture phase. Sweet ^_^
}
GameObject go = GuiLookup.GetGameObject((Component) e.Target);
if (null == go)
{
_hoveredComponent = null;
ClickSignal.Emit(null, e);
return;
}
ComponentAdapter adapter = (ComponentAdapter)go.GetComponent(typeof(ComponentAdapter));
if (null == adapter)
{
_hoveredComponent = null;
ClickSignal.Emit(null, e);
return;
}
if (null == adapter.Component)
{
_hoveredComponent = null;
ClickSignal.Emit(null, e);
return;
}
_hoveredComponent = adapter.Component;
ClickSignal.Emit(_hoveredComponent, e);
}
示例13: MouseEventHandler
private void MouseEventHandler(Event e)
{
//Debug.Log("MouseEventHandler: " + e);
MouseEvent mouseEvent = (MouseEvent)e;
//Debug.Log("e: " + e.Type + "; " + mouseEvent.ButtonDown);
switch (e.Type)
{
case MouseEvent.ROLL_OVER:
{
// if the user rolls over while holding the mouse button
if (mouseEvent.ButtonDown && !MouseCaptured)
return;
Hovered = true;
break;
}
case MouseEvent.ROLL_OUT:
{
Hovered = false;
break;
}
case MouseEvent.MOUSE_DOWN:
{
// When the button is down we need to listen for mouse events outside the button so that
// we update the state appropriately on mouse up. Whenever mouseCaptured changes to false,
// it will take care to remove those handlers.
//Debug.Log("mousedown");
SystemManager.Instance.MouseUpSignal.Connect(MouseUpSlot, true);
MouseCaptured = true;
break;
}
case MouseEvent.MOUSE_UP:
{
//Debug.Log("mouseup");
// Call buttonReleased() if we mouse up on the button and if the mouse
// was captured before.
if (e.Target == this)
{
Hovered = true;
if (_mouseCaptured)
{
ButtonReleased();
MouseCaptured = false;
}
}
break;
}
case MouseEvent.CLICK:
{
if (!Enabled)
e.CancelAndStopPropagation();
else
ClickHandler(e);
return;
}
}
}