protected override bool OnKeyDown(KeyDownEvent e) { if (e.Repeat) { return(false); } switch (e.Key) { case Key.Delete: if (e.ShiftPressed) { if (!Beatmap.IsDefault) { delete(Beatmap.Value.BeatmapSetInfo); } return(true); } break; } return(base.OnKeyDown(e)); }
protected internal override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); if (evt == null) { return; } var showPopupMenu = false; KeyDownEvent kde = (evt as KeyDownEvent); if (kde != null) { if ((kde.keyCode == KeyCode.Space) || (kde.keyCode == KeyCode.KeypadEnter) || (kde.keyCode == KeyCode.Return)) { showPopupMenu = true; } } else if ((evt as MouseDownEvent)?.button == (int)MouseButton.LeftMouse) { var mde = (MouseDownEvent)evt; if (visualInput.ContainsPoint(visualInput.WorldToLocal(mde.mousePosition))) { showPopupMenu = true; } } if (showPopupMenu) { ShowMenu(); evt.StopPropagation(); } }
void SelectAllTypes(bool state, EventTypeSelection eventTypeSelection = EventTypeSelection.All) { foreach (KeyValuePair <long, bool> v in m_State.ToList()) { long eventTypeId = v.Key; if (eventTypeSelection == EventTypeSelection.All || (eventTypeSelection == EventTypeSelection.Mouse && (eventTypeId == MouseMoveEvent.TypeId() || eventTypeId == MouseOverEvent.TypeId() || eventTypeId == MouseDownEvent.TypeId() || eventTypeId == MouseUpEvent.TypeId() || eventTypeId == WheelEvent.TypeId() || eventTypeId == ContextClickEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Keyboard && (eventTypeId == KeyDownEvent.TypeId() || eventTypeId == KeyUpEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Drag && (eventTypeId == DragUpdatedEvent.TypeId() || eventTypeId == DragPerformEvent.TypeId() || eventTypeId == DragExitedEvent.TypeId())) || (eventTypeSelection == EventTypeSelection.Command && (eventTypeId == ValidateCommandEvent.TypeId() || eventTypeId == ExecuteCommandEvent.TypeId()))) { m_State[eventTypeId] = state; } else { // Unaffected should be reset to false m_State[eventTypeId] = false; } } UpdateValue(); }
protected override bool OnKeyDown(KeyDownEvent e) { switch (e.Key) { case Key.Left: seek(e, -1); return(true); case Key.Right: seek(e, 1); return(true); case Key.S: if (e.ControlPressed) { saveBeatmap(); return(true); } break; } return(base.OnKeyDown(e)); }
protected override bool OnKeyDown(KeyDownEvent e) { secondaryActive = e.ShiftPressed; updateText(); return(base.OnKeyDown(e)); }
public void SetOnKeyDownEvent(KeyDownEvent callback) { _onKeyDown = callback; }
private void OnKeyDown(KeyDownEvent evt) { evt.Handled = false; pressedKeys.Add(evt.KeyData); }
public virtual bool OnToolKeyDown(KeyDownEvent e) => false;
private void DoOnGUI(Event evt, Matrix4x4 worldTransform, Rect clippingRect, bool isComputingLayout = false) { // Extra checks are needed here because client code might have changed the IMGUIContainer // since we enter HandleIMGUIEvent() if (m_OnGUIHandler == null || panel == null) { return; } // Save the GUIClip count to make sanity checks after calling the OnGUI handler int guiClipCount = GUIClip.Internal_GetCount(); SaveGlobals(); UIElementsUtility.BeginContainerGUI(cache, evt, this); // For the IMGUI, we need to update the GUI.color with the actual play mode tint ... // In fact, this is taken from EditorGUIUtility.ResetGUIState(). // Here, the play mode tint is either white (no tint, or not in play mode) or the right color (if in play mode) GUI.color = UIElementsUtility.editorPlayModeTintColor; // From now on, Event.current is either evt or a copy of evt. // Since Event.current may change while being processed, we do not rely on evt below but use Event.current instead. if (Event.current.type != EventType.Layout) { if (lostFocus) { if (focusController != null) { // We dont want to clear the GUIUtility.keyboardControl if another IMGUIContainer // just set it in the if (receivedFocus) block below. So we only clear it if either // // - there is no focused element // - we are the currently focused element (that would be surprising) // - the currently focused element is not an IMGUIContainer (in this case, // GUIUtility.keyboardControl should be 0). if (focusController.focusedElement == null || focusController.focusedElement == this || !(focusController.focusedElement is IMGUIContainer) || useUIElementsFocusStyle) { GUIUtility.keyboardControl = 0; focusController.imguiKeyboardControl = 0; } } lostFocus = false; } if (receivedFocus) { // If we just received the focus and GUIUtility.keyboardControl is not already one of our control, // set the GUIUtility.keyboardControl to our first or last focusable control. if (focusChangeDirection != FocusChangeDirection.unspecified && focusChangeDirection != FocusChangeDirection.none) { // We assume we are using the VisualElementFocusRing. if (focusChangeDirection == VisualElementFocusChangeDirection.left) { GUIUtility.SetKeyboardControlToLastControlId(); } else if (focusChangeDirection == VisualElementFocusChangeDirection.right) { GUIUtility.SetKeyboardControlToFirstControlId(); } } else if (useUIElementsFocusStyle) { // When the direction is not set, this is because we are coming back to this specific IMGUIContainer // with a mean other than TAB, we need to make sure to return to the element that was focused before... if ((focusController == null) || (focusController.imguiKeyboardControl == 0)) { GUIUtility.SetKeyboardControlToFirstControlId(); } else { GUIUtility.keyboardControl = focusController.imguiKeyboardControl; } } receivedFocus = false; focusChangeDirection = FocusChangeDirection.unspecified; if (focusController != null) { focusController.imguiKeyboardControl = GUIUtility.keyboardControl; } } // We intentionally don't send the NewKeuboardFocus command here since it creates an issue with the AutomatedWindow // newKeyboardFocusControlID = GUIUtility.keyboardControl; } EventType originalEventType = Event.current.type; bool isExitGUIException = false; try { // If we are computing the layout, we should not try to get the worldTransform... // it is dependant on the layout, which is being calculated (thus, not good) if (!isComputingLayout) { // Push UIElements matrix in GUIClip to make mouse position relative to the IMGUIContainer top left using (new GUIClip.ParentClipScope(worldTransform, clippingRect)) { m_OnGUIHandler(); } } else { m_OnGUIHandler(); } } catch (Exception exception) { // only for layout events: we always intercept any exceptions to not interrupt event processing if (originalEventType == EventType.Layout) { isExitGUIException = GUIUtility.IsExitGUIException(exception); if (!isExitGUIException) { Debug.LogException(exception); } } else { // rethrow event if not in layout throw; } } finally { if (Event.current.type != EventType.Layout) { int currentKeyboardFocus = GUIUtility.keyboardControl; int result = GUIUtility.CheckForTabEvent(Event.current); if (focusController != null) { if (result < 0) { // If CheckForTabEvent returns -1 or -2, we have reach the end/beginning of its control list. // We should switch the focus to the next VisualElement. Focusable currentFocusedElement = focusController.focusedElement; using (KeyDownEvent e = KeyDownEvent.GetPooled('\t', KeyCode.Tab, result == -1 ? EventModifiers.None : EventModifiers.Shift)) { focusController.SwitchFocusOnEvent(e); } if (currentFocusedElement == this) { if (focusController.focusedElement == this) { // We still have the focus. We should cycle around our controls. if (result == -2) { GUIUtility.SetKeyboardControlToLastControlId(); } else if (result == -1) { GUIUtility.SetKeyboardControlToFirstControlId(); } newKeyboardFocusControlID = GUIUtility.keyboardControl; focusController.imguiKeyboardControl = GUIUtility.keyboardControl; } else { // We lost the focus. Set the focused element ID to 0 until next // IMGUIContainer have a chance to set it to its own control. // Doing this will ensure we draw ourselves without any focused control. GUIUtility.keyboardControl = 0; focusController.imguiKeyboardControl = 0; } } } else if (result > 0) { // A positive result indicates that the focused control has changed to one of our elements; result holds the control id. focusController.imguiKeyboardControl = GUIUtility.keyboardControl; newKeyboardFocusControlID = GUIUtility.keyboardControl; } else if (result == 0) { // This means the event is not a tab. Synchronize our focus info with IMGUI. if ((currentKeyboardFocus != GUIUtility.keyboardControl) || (originalEventType == EventType.MouseDown)) { focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this); } else if (GUIUtility.keyboardControl != focusController.imguiKeyboardControl) { // Here we want to resynchronize our internal state ... newKeyboardFocusControlID = GUIUtility.keyboardControl; if (focusController.focusedElement == this) { // In this case, the focused element is the right one in the Focus Controller... we are just updating the internal imguiKeyboardControl focusController.imguiKeyboardControl = GUIUtility.keyboardControl; } else { // In this case, the focused element is NOT the right one in the Focus Controller... we also have to refocus... focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this); } } } } // Cache the fact that we have focusable controls or not. hasFocusableControls = GUIUtility.HasFocusableControls(); } } // This will copy Event.current into evt. UIElementsUtility.EndContainerGUI(evt); RestoreGlobals(); if (!isExitGUIException) { // This is the same logic as GUIClipState::EndOnGUI if (evt.type != EventType.Ignore && evt.type != EventType.Used) { int currentCount = GUIClip.Internal_GetCount(); if (currentCount > guiClipCount) { Debug.LogError("GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced."); } else if (currentCount < guiClipCount) { Debug.LogError("GUI Error: You are popping more GUIClips than you are pushing. Make sure they are balanced."); } } } // Clear extraneous GUIClips while (GUIClip.Internal_GetCount() > guiClipCount) { GUIClip.Internal_Pop(); } if (evt.type == EventType.Used) { IncrementVersion(VersionChangeType.Repaint); } }
public void OnKeyDown() { KeyDownEvent.Invoke(); }
private void KeyboardHook_OnKeyDownEvent(object sender, KeyDownEvent e) { numUnlock.ChangeKeyState(e.KeyData, 0); }
/// <summary> /// Initializes static members of the <see cref="DropDown"/> class. /// </summary> static DropDown() { FocusableProperty.OverrideDefaultValue <DropDown>(true); SelectedItemProperty.Changed.AddClassHandler <DropDown>(x => x.SelectedItemChanged); KeyDownEvent.AddClassHandler <DropDown>(x => x.OnKeyDown, Interactivity.RoutingStrategies.Tunnel); }
protected override bool OnKeyDown(KeyDownEvent e) { if (e.ControlPressed || e.AltPressed || e.SuperPressed) { return(false); } switch (e.Key) { case Key.Left: seek(e, -1); return(true); case Key.Right: seek(e, 1); return(true); // Track traversal keys. // Matching osu-stable implementations. case Key.Z: // Seek to first object time, or track start if already there. double?firstObjectTime = editorBeatmap.HitObjects.FirstOrDefault()?.StartTime; if (firstObjectTime == null || clock.CurrentTime == firstObjectTime) { clock.Seek(0); } else { clock.Seek(firstObjectTime.Value); } return(true); case Key.X: // Restart playback from beginning of track. clock.Seek(0); clock.Start(); return(true); case Key.C: // Pause or resume. if (clock.IsRunning) { clock.Stop(); } else { clock.Start(); } return(true); case Key.V: // Seek to last object time, or track end if already there. // Note that in osu-stable subsequent presses when at track end won't return to last object. // This has intentionally been changed to make it more useful. double?lastObjectTime = editorBeatmap.HitObjects.LastOrDefault()?.GetEndTime(); if (lastObjectTime == null || clock.CurrentTime == lastObjectTime) { clock.Seek(clock.TrackLength); } else { clock.Seek(lastObjectTime.Value); } return(true); } return(base.OnKeyDown(e)); }
public virtual bool OnKeyDown(KeyDownEvent e) { return(false); }
private void OnKeyDownShortcut(KeyDownEvent evt) { currentView.OnKeyDownShortcut(evt); }
public void OnFDown(KeyDownEvent evt) { Debug.Log("here"); workspace.transform.scale = Vector3.one; workspace.transform.position = Vector3.zero; }
/// <summary> /// Fires the KeyDown event with the given parameters. /// </summary> /// <param name="keyboardInfo">Details about the key pressed, along with modifier key states.</param> public void KeyDown(KeyboardInfo keyboardInfo) { KeyDownEvent?.Invoke(this, keyboardInfo); }
protected override bool OnKeyDown(KeyDownEvent e) { updateText(e); return(base.OnKeyDown(e)); }
// only KeyDown is blocking protected override bool OnKeyDown(KeyDownEvent e) { ++KeyDownCount; return(true); }
protected override bool OnKeyDown(KeyDownEvent e) { return(PressBlocked = base.OnKeyDown(e)); }
void HandleKeyDown(KeyDownEvent e) { var renderer = GetSubsystem <Renderer>(); switch (e.Key) { case Constants.KEY_ESCAPE: BackToSelector(); return; case Constants.KEY_F1: GetSubsystem <UI>().ToggleConsole(); return; case Constants.KEY_F2: GetSubsystem <UI>().ToggleDebugHud(); return; } switch (e.Key) { case Constants.KEY_1: var quality = renderer.TextureQuality; ++quality; if (quality > 2) { quality = 0; } renderer.TextureQuality = quality; break; case Constants.KEY_2: var mquality = renderer.MaterialQuality; ++mquality; if (mquality > 2) { mquality = 0; } renderer.MaterialQuality = mquality; break; case Constants.KEY_3: renderer.SpecularLighting = !renderer.SpecularLighting; break; case Constants.KEY_4: renderer.DrawShadows = !renderer.DrawShadows; break; case Constants.KEY_5: var shadowMapSize = renderer.ShadowMapSize; shadowMapSize *= 2; if (shadowMapSize > 2048) { shadowMapSize = 512; } renderer.ShadowMapSize = shadowMapSize; break; // shadow depth and filtering quality case Constants.KEY_6: var q = (int)renderer.ShadowQuality++; if (q > 3) { q = 0; } renderer.ShadowQuality = (ShadowQuality)q; break; // occlusion culling case Constants.KEY_7: var o = !(renderer.MaxOccluderTriangles > 0); renderer.MaxOccluderTriangles = o ? 5000 : 0; break; // instancing case Constants.KEY_8: renderer.DynamicInstancing = !renderer.DynamicInstancing; break; case Constants.KEY_9: Image screenshot = new Image(); GetSubsystem <Graphics>().TakeScreenShot(screenshot); screenshot.SavePNG(GetSubsystem <FileSystem>().ProgramDir + $"Data/Screenshot_{GetType().Name}_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)}.png"); break; } }
void SetSelectedElementInResultsList(KeyDownEvent evt) { if (evt.keyCode == config.InsertLineKey && (evt.modifiers & config.InsertLineModifier) != 0) { m_SelectionCallback(new SearcherItem("Generic Text")); return; } if (m_ListView.childCount == 0) { return; } int index; switch (evt.keyCode) { case KeyCode.Escape: m_SelectionCallback(null); break; case KeyCode.Return: case KeyCode.KeypadEnter: if (m_ListView.selectedIndex != -1) { m_SelectionCallback((SearcherItem)m_ListView.selectedItem); } else { m_SelectionCallback(null); } break; case KeyCode.LeftArrow: index = m_ListView.selectedIndex; if (index >= 0 && index < m_ListView.itemsSource.Count) { Collapse(m_ListView.selectedItem as SearcherItem); } break; case KeyCode.RightArrow: index = m_ListView.selectedIndex; if (index >= 0 && index < m_ListView.itemsSource.Count) { Expand(m_ListView.selectedItem as SearcherItem); } break; case KeyCode.UpArrow: case KeyCode.DownArrow: case KeyCode.PageUp: case KeyCode.PageDown: index = m_ListView.selectedIndex; if (index >= 0 && index < m_ListView.itemsSource.Count) { m_ListView.OnKeyDown(evt); } break; } }
protected override bool OnKeyDown(KeyDownEvent e) { ChangeKeyEvent(e); return(base.OnKeyDown(e)); }
protected virtual void KeyDownCallback(KeyDownEvent e) { if (EditorWindow.focusedWindow is BaseGraphWindow) { if (e.keyCode == KeyCode.Z && e.commandKey) { //e.StopPropagation(); } } if (e.keyCode == KeyCode.S && e.commandKey) { SaveGraphToDisk(); e.StopPropagation(); } else if (e.keyCode == KeyCode.Backspace || e.keyCode == KeyCode.Delete) { var baseStackNodeViewList = new List <BaseStackNodeView>(); var baseNodeViewList = new List <BaseNodeView>(); var groupViewList = new List <GroupView>(); var stackCount = 0; var nodeCount = 0; var groupCount = 0; foreach (var selectable in selection) { switch (selectable) { case BaseNodeView selectedNodeView: baseNodeViewList.Add(selectedNodeView); nodeCount++; break; case GroupView selectedGroupView: groupViewList.Add(selectedGroupView); groupCount++; break; case BaseStackNodeView baseStackNodeView: baseStackNodeViewList.Add(baseStackNodeView); stackCount++; break; } } for (var i = 0; i < nodeCount; i++) { graph.RemoveNode(baseNodeViewList[i].nodeTarget); var iPortsCount = baseNodeViewList[i].inputPortViews.Count; var oPortsCount = baseNodeViewList[i].outputPortViews.Count; for (var j = 0; j < iPortsCount; j++) { var edgesCopy = baseNodeViewList[i].inputPortViews[j].GetEdges().ToList(); foreach (var edge in edgesCopy) { Disconnect(edge); } } for (var j = 0; j < oPortsCount; j++) { var edgesCopy = baseNodeViewList[i].outputPortViews[j].GetEdges().ToList(); foreach (var edge in edgesCopy) { Disconnect(edge); } } RemoveNodeView(baseNodeViewList[i]); } for (var i = 0; i < stackCount; i++) { var stackNodeView = baseStackNodeViewList[i]; stackNodeView.RemoveAllChildsFromThisStack(); // graph.RemoveStackNode(stackNodeView.stackNode); // RemoveStackNodeView(stackNodeView); //ReloadView(); //TODO: Remove the stack without removing its nodes. } for (var i = 0; i < groupCount; i++) { var graphElement = groupViewList[i]; graphElement.RemoveElementsFromThisGroup(); graph.RemoveGroup(graphElement.@group); RemoveElement(graphElement); } if (nodeCount > 0 || groupCount > 0) { e.StopPropagation(); } } else if (selection.Count > 0 && e.keyCode == KeyCode.G) { // var position = new Vector2(100000,100000); // var selectedNodeGUIDs = new List<string>(); // for(var i = 0; i < selection.Count; i++) // { // if(!(selection[i] is BaseNodeView)) continue; // // var selected = selection[i] as BaseNodeView; // // if(selected == null) continue; // // var nodeRect = selected.GetPosition(); // if(nodeRect.x < position.x) position.x = nodeRect.x; // if(nodeRect.y < position.y) position.y = nodeRect.y; // // selectedNodeGUIDs.Add(selected.nodeTarget.GUID); // } // position -= new Vector2(9f,42f); // Estimated position // var newGroup = new Group("New Group", position) {innerNodeGUIDs = selectedNodeGUIDs}; // AddGroup(newGroup); // TODO: Uncomment this when groups are stable. AddSelectionsToGroup(AddGroup(new Group("New Group", new Vector2(0, 0)))); e.StopPropagation(); } else if (selection.Count > 0 && e.keyCode == KeyCode.S) { // TODO: Uncomment this when stacks are stable. // var position = new Vector2(100000,100000); // var selectedNodeGUIDs = new List<string>(); // for(var i = 0; i < selection.Count; i++) // { // if(!(selection[i] is BaseNodeView)) continue; // // var selected = selection[i] as BaseNodeView; // // if(selected == null) continue; // // var nodeRect = selected.GetPosition(); // if(nodeRect.x < position.x) position.x = nodeRect.x; // if(nodeRect.y < position.y) position.y = nodeRect.y; // // selectedNodeGUIDs.Add(selected.nodeTarget.GUID); // } // position -= new Vector2(10f,30f); // Estimated position // var newStack = new BaseStackNode(position) {nodeGUIDs = selectedNodeGUIDs}; // AddStackNode(newStack); // e.StopPropagation(); } else if (nodeViews.Count > 0 && (e.commandKey || e.ctrlKey) && e.altKey) { // Node Aligning shortcuts switch (e.keyCode) { case KeyCode.LeftArrow: nodeViews[0].AlignToLeft(); e.StopPropagation(); break; case KeyCode.RightArrow: nodeViews[0].AlignToRight(); e.StopPropagation(); break; case KeyCode.UpArrow: nodeViews[0].AlignToTop(); e.StopPropagation(); break; case KeyCode.DownArrow: nodeViews[0].AlignToBottom(); e.StopPropagation(); break; case KeyCode.C: nodeViews[0].AlignToCenter(); e.StopPropagation(); break; case KeyCode.M: nodeViews[0].AlignToMiddle(); e.StopPropagation(); break; } } }
void UpdateEventbaseInfo(EventDebuggerEventRecord eventBase, IEventHandler focused, IEventHandler capture) { ClearEventbaseInfo(); if (eventBase == null) { return; } m_EventbaseInfo.text += "Focused element: " + EventDebugger.GetObjectDisplayName(focused) + "\n"; m_EventbaseInfo.text += "Capture element: " + EventDebugger.GetObjectDisplayName(capture) + "\n"; if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Mouse position: " + eventBase.mousePosition + "\n"; m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { m_EventbaseInfo.text += "Modifiers: " + eventBase.modifiers + "\n"; } if (eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId()) { m_EventbaseInfo.text += "Button: " + (eventBase.button == 0 ? "Left" : eventBase.button == 1 ? "Middle" : "Right") + "\n"; m_EventbaseInfo.text += "Click count: " + eventBase.clickCount + "\n"; } if (eventBase.eventTypeId == MouseMoveEvent.TypeId() || eventBase.eventTypeId == MouseOverEvent.TypeId() || eventBase.eventTypeId == MouseOutEvent.TypeId() || eventBase.eventTypeId == MouseDownEvent.TypeId() || eventBase.eventTypeId == MouseUpEvent.TypeId() || eventBase.eventTypeId == MouseEnterEvent.TypeId() || eventBase.eventTypeId == MouseLeaveEvent.TypeId() || eventBase.eventTypeId == DragEnterEvent.TypeId() || eventBase.eventTypeId == DragLeaveEvent.TypeId() || eventBase.eventTypeId == DragUpdatedEvent.TypeId() || eventBase.eventTypeId == DragPerformEvent.TypeId() || eventBase.eventTypeId == DragExitedEvent.TypeId() || eventBase.eventTypeId == ContextClickEvent.TypeId() || eventBase.eventTypeId == WheelEvent.TypeId() || eventBase.eventTypeId == PointerMoveEvent.TypeId() || eventBase.eventTypeId == PointerOverEvent.TypeId() || eventBase.eventTypeId == PointerOutEvent.TypeId() || eventBase.eventTypeId == PointerDownEvent.TypeId() || eventBase.eventTypeId == PointerUpEvent.TypeId() || eventBase.eventTypeId == PointerCancelEvent.TypeId() || eventBase.eventTypeId == PointerStationaryEvent.TypeId() || eventBase.eventTypeId == PointerEnterEvent.TypeId() || eventBase.eventTypeId == PointerLeaveEvent.TypeId()) { m_EventbaseInfo.text += "Pressed buttons: " + eventBase.pressedButtons + "\n"; } if (eventBase.eventTypeId == WheelEvent.TypeId()) { m_EventbaseInfo.text += "Mouse delta: " + eventBase.delta + "\n"; } if (eventBase.eventTypeId == KeyDownEvent.TypeId() || eventBase.eventTypeId == KeyUpEvent.TypeId()) { if (char.IsControl(eventBase.character)) { m_EventbaseInfo.text += "Character: \\" + (byte)(eventBase.character) + "\n"; } else { m_EventbaseInfo.text += "Character: " + eventBase.character + "\n"; } m_EventbaseInfo.text += "Key code: " + eventBase.keyCode + "\n"; } if (eventBase.eventTypeId == ValidateCommandEvent.TypeId() || eventBase.eventTypeId == ExecuteCommandEvent.TypeId()) { m_EventbaseInfo.text += "Command: " + eventBase.commandName + "\n"; } }
public void Restart(KeyDownEvent ev) { Engine.SceneHost.Pop(); Engine.SceneHost.Push(Engine.SceneHost.CreateGlobal<MainScene>()); ev.Intercept = true; }
private void OnKeyDownShortcut(KeyDownEvent evt) { if (selectedItem == null) { return; } if (evt.keyCode == KeyCode.Tab) { OnFocusChange(); evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.UpArrow) { if (selectedItem.previousItem != null) { Select(selectedItem.previousItem); ScrollIfNeeded(); } else if (selectedItem.packageGroup.previousGroup != null && selectedItem.packageGroup.previousGroup.visible) { Select(selectedItem.packageGroup.previousGroup.lastPackage); ScrollIfNeeded(); } evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.DownArrow) { if (selectedItem.nextItem != null) { Select(selectedItem.nextItem); ScrollIfNeeded(); } else if (selectedItem.packageGroup.nextGroup != null && selectedItem.packageGroup.nextGroup.visible) { Select(selectedItem.packageGroup.nextGroup.firstPackage); ScrollIfNeeded(); } evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.PageUp) { if (selectedItem.packageGroup != null) { if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage) { Select(selectedItem.packageGroup.firstPackage); ScrollIfNeeded(); } else if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem.packageGroup.previousGroup != null && selectedItem.packageGroup.previousGroup.visible) { Select(selectedItem.packageGroup.previousGroup.lastPackage); ScrollIfNeeded(); } else if (selectedItem != selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage) { Select(selectedItem.packageGroup.firstPackage); ScrollIfNeeded(); } } evt.StopPropagation(); return; } if (evt.keyCode == KeyCode.PageDown) { if (selectedItem.packageGroup != null) { if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage) { Select(selectedItem.packageGroup.lastPackage); ScrollIfNeeded(); } else if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem.packageGroup.nextGroup != null && selectedItem.packageGroup.nextGroup.visible) { Select(selectedItem.packageGroup.nextGroup.firstPackage); ScrollIfNeeded(); } else if (selectedItem != selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage) { Select(selectedItem.packageGroup.lastPackage); ScrollIfNeeded(); } } evt.StopPropagation(); } }
protected override bool OnKeyDown(KeyDownEvent e) { // we don't want to handle escape key. return(false); }
protected override bool OnKeyDown(KeyDownEvent e) { return(handleAlert() ? true : base.OnKeyDown(e)); }
void HandleKeyDown(KeyDownEvent e) { var renderer = GetSubsystem<Renderer>(); switch (e.Key) { case Constants.KEY_ESCAPE: BackToSelector(); return; case Constants.KEY_F1: GetSubsystem<UI>().ToggleConsole(); return; case Constants.KEY_F2: GetSubsystem<UI>().ToggleDebugHud(); return; } switch (e.Key) { case Constants.KEY_1: var quality = renderer.TextureQuality; ++quality; if (quality > 2) quality = 0; renderer.TextureQuality = quality; break; case Constants.KEY_2: var mquality = renderer.MaterialQuality; ++mquality; if (mquality > 2) mquality = 0; renderer.MaterialQuality = mquality; break; case Constants.KEY_3: renderer.SpecularLighting = !renderer.SpecularLighting; break; case Constants.KEY_4: renderer.DrawShadows = !renderer.DrawShadows; break; case Constants.KEY_5: var shadowMapSize = renderer.ShadowMapSize; shadowMapSize *= 2; if (shadowMapSize > 2048) shadowMapSize = 512; renderer.ShadowMapSize = shadowMapSize; break; // shadow depth and filtering quality case Constants.KEY_6: var q = (int)renderer.ShadowQuality++; if (q > 3) q = 0; renderer.ShadowQuality = (ShadowQuality)q; break; // occlusion culling case Constants.KEY_7: var o = !(renderer.MaxOccluderTriangles > 0); renderer.MaxOccluderTriangles = o ? 5000 : 0; break; // instancing case Constants.KEY_8: renderer.DynamicInstancing = !renderer.DynamicInstancing; break; case Constants.KEY_9: Image screenshot = new Image(); GetSubsystem<Graphics>().TakeScreenShot(screenshot); screenshot.SavePNG(GetSubsystem<FileSystem>().ProgramDir + $"Data/Screenshot_{GetType().Name}_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)}.png"); break; } }
private void DoOnGUI(Event evt) { if (m_OnGUIHandler == null || panel == null) { return; } // Save the GUIClip count to make sanity checks after calling the OnGUI handler int guiClipCount = GUIClip.Internal_GetCount(); SaveGlobals(); UIElementsUtility.BeginContainerGUI(cache, evt, this); if (evt.type != EventType.Layout) { if (lostFocus) { if (focusController != null) { // We dont want to clear the GUIUtility.keyboardControl if another IMGUIContainer // just set it in the if (receivedFocus) block below. So we only clear it if either // // - there is no focused element // - we are the currently focused element (that would be surprising) // - the currently focused element is not an IMGUIContainer (in this case, // GUIUtility.keyboardControl should be 0). if (focusController.focusedElement == null || focusController.focusedElement == this || !(focusController.focusedElement is IMGUIContainer)) { GUIUtility.keyboardControl = 0; focusController.imguiKeyboardControl = 0; } } lostFocus = false; } if (receivedFocus) { // If we just received the focus and GUIUtility.keyboardControl is not already one of our control, // set the GUIUtility.keyboardControl to our first or last focusable control. if (focusChangeDirection != FocusChangeDirection.unspecified && focusChangeDirection != FocusChangeDirection.none) { // We assume we are using the VisualElementFocusRing. if (focusChangeDirection == VisualElementFocusChangeDirection.left) { GUIUtility.SetKeyboardControlToLastControlId(); } else if (focusChangeDirection == VisualElementFocusChangeDirection.right) { GUIUtility.SetKeyboardControlToFirstControlId(); } } receivedFocus = false; focusChangeDirection = FocusChangeDirection.unspecified; if (focusController != null) { focusController.imguiKeyboardControl = GUIUtility.keyboardControl; } } // We intentionally don't send the NewKeuboardFocus command here since it creates an issue with the AutomatedWindow // newKeyboardFocusControlID = GUIUtility.keyboardControl; } GUIDepth = GUIUtility.Internal_GetGUIDepth(); EventType originalEventType = Event.current.type; bool isExitGUIException = false; try { // On a layout event, we should not try to get the worldTransform... it is dependant on the layout, which is being calculated (thus, not good) if (originalEventType != EventType.Layout) { Matrix4x4 currentTransform; Rect clippingRect; GetCurrentTransformAndClip(this, evt, out currentTransform, out clippingRect); // Push UIElements matrix in GUIClip to make mouse position relative to the IMGUIContainer top left using (new GUIClip.ParentClipScope(currentTransform, clippingRect)) { m_OnGUIHandler(); } } else { m_OnGUIHandler(); } } catch (Exception exception) { // only for layout events: we always intercept any exceptions to not interrupt event processing if (originalEventType == EventType.Layout) { isExitGUIException = GUIUtility.IsExitGUIException(exception); if (!isExitGUIException) { Debug.LogException(exception); } } else { // rethrow event if not in layout throw; } } finally { if (evt.type != EventType.Layout) { int currentKeyboardFocus = GUIUtility.keyboardControl; int result = GUIUtility.CheckForTabEvent(evt); if (focusController != null) { if (result < 0) { // If CheckForTabEvent returns -1 or -2, we have reach the end/beginning of its control list. // We should switch the focus to the next VisualElement. Focusable currentFocusedElement = focusController.focusedElement; using (KeyDownEvent e = KeyDownEvent.GetPooled('\t', KeyCode.Tab, result == -1 ? EventModifiers.None : EventModifiers.Shift)) { focusController.SwitchFocusOnEvent(e); } if (currentFocusedElement == this) { if (focusController.focusedElement == this) { // We still have the focus. We should cycle around our controls. if (result == -2) { GUIUtility.SetKeyboardControlToLastControlId(); } else if (result == -1) { GUIUtility.SetKeyboardControlToFirstControlId(); } newKeyboardFocusControlID = GUIUtility.keyboardControl; focusController.imguiKeyboardControl = GUIUtility.keyboardControl; } else { // We lost the focus. Set the focused element ID to 0 until next // IMGUIContainer have a chance to set it to its own control. // Doing this will ensure we draw ourselves without any focused control. GUIUtility.keyboardControl = 0; focusController.imguiKeyboardControl = 0; } } } else if (result > 0) { // A positive result indicates that the focused control has changed to one of our elements; result holds the control id. focusController.imguiKeyboardControl = GUIUtility.keyboardControl; newKeyboardFocusControlID = GUIUtility.keyboardControl; } else if (result == 0) { // This means the event is not a tab. Synchronize our focus info with IMGUI. if (currentKeyboardFocus != GUIUtility.keyboardControl || originalEventType == EventType.MouseDown) { focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this); } } } // Cache the fact that we have focusable controls or not. hasFocusableControls = GUIUtility.HasFocusableControls(); } } // The Event will probably be nuked with the next function call, so we get its type now. EventType eventType = Event.current.type; UIElementsUtility.EndContainerGUI(); RestoreGlobals(); if (!isExitGUIException) { // This is the same logic as GUIClipState::EndOnGUI if (eventType != EventType.Ignore && eventType != EventType.Used) { int currentCount = GUIClip.Internal_GetCount(); if (currentCount > guiClipCount) { Debug.LogError("GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)"); } else if (currentCount < guiClipCount) { Debug.LogError("GUI Error: You are popping more GUIClips than you are pushing. Make sure they are balanced)"); } } } // Clear extraneous GUIClips while (GUIClip.Internal_GetCount() > guiClipCount) { GUIClip.Internal_Pop(); } if (eventType == EventType.Used) { Dirty(ChangeType.Repaint); } }
void StopKeyPropagation(KeyDownEvent e) { e.StopPropagation(); }