/// <summary> /// Call this inside the OnGUI function of the class to check for any events. /// </summary> public void ProcessEvents() { var eventType = Event.current.type; if (_mouseEventMap.ContainsKey(eventType)) { _mouseEventMap[eventType].ForEach(x => x.InvokeSafe()); } if (eventType == EventType.KeyDown) { KeyPressed.InvokeSafe(new EditorKeyboardEvent()); // TODO: Replace with delete command. There is one...somewhere...apparently...*shrug* if (Event.current.keyCode == KeyCode.Backspace) { DeletePressed.InvokeSafe(); } } if (eventType == EventType.KeyUp) { KeyPressed.InvokeSafe(new EditorKeyboardEvent()); } MousePosition = Event.current.mousePosition; }
/// <summary> /// Adds a row to the task display. /// </summary> public void AddItem(string description, bool isCompleted, bool belongsToUser) { int row = taskPanel.Controls.Count / 3; taskPanel.Controls.Add(new Label() { Text = description }); if (belongsToUser) { Button delete = new Button() { Text = "X" }; taskPanel.Controls.Add(delete); delete.Click += (s, e) => DeletePressed?.Invoke(row);; } else { taskPanel.Controls.Add(new Label()); } if (isCompleted) { taskPanel.Controls.Add(new Label() { Text = "Done" }); } else if (belongsToUser) { Button finished = new Button() { Text = "Done" }; taskPanel.Controls.Add(finished); finished.Click += (s, e) => DonePressed?.Invoke(row); } else { taskPanel.Controls.Add(new Label()); } }
private void TgtDelete_Click(object sender, EventArgs e) { DeletePressed?.Invoke(this, EventArgs.Empty); }
protected void OnDeletePressed(KeyPressedEventArgs e) { DeletePressed?.Invoke(this, e); }