mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Add button click and checkbox toggle handlers for UI controls
This commit is contained in:
@@ -18,8 +18,11 @@ public class Button() : Control("Button")
|
||||
set => SetProperty(nameof(TextColor), ref field, value);
|
||||
} = Color.Black;
|
||||
|
||||
public void Click()
|
||||
public override void HandleMouseEvent(MouseEvent mouseEvent)
|
||||
{
|
||||
OnClick?.Invoke(this, EventArgs.Empty);
|
||||
if (mouseEvent.Type == MouseEventType.ButtonDown && mouseEvent.Button == MouseButton.Left)
|
||||
{
|
||||
OnClick?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,4 +27,12 @@ public class CheckBox() : Control("CheckBox")
|
||||
get;
|
||||
set => SetProperty(nameof(TextColor), ref field, value);
|
||||
} = Color.White;
|
||||
|
||||
public override void HandleMouseEvent(MouseEvent mouseEvent)
|
||||
{
|
||||
if (mouseEvent.Type == MouseEventType.ButtonDown && mouseEvent.Button == MouseButton.Left)
|
||||
{
|
||||
IsChecked = !IsChecked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@ public sealed class Window(string title, int processId, int id, IRenderSource re
|
||||
uiElements.Add(uiElementId, uiElement);
|
||||
}
|
||||
|
||||
lock (controlsLock)
|
||||
if (uiElement is Control control)
|
||||
{
|
||||
if (uiElement is Control control)
|
||||
lock (controlsLock)
|
||||
{
|
||||
controls.Add(uiElementId, control);
|
||||
}
|
||||
|
||||
@@ -57,20 +57,20 @@ public static class WindowManager
|
||||
activeInteractWindow = null;
|
||||
}
|
||||
|
||||
wasLeftButtonDown = leftButtonDown;
|
||||
wasRightButtonDown = rightButtonDown;
|
||||
wasMiddleButtonDown = middleButtonDown;
|
||||
|
||||
while (KeyboardManager.TryReadKey(out KeyEvent? keyEvent) && keyEvent is not null)
|
||||
{
|
||||
focusedWindow?.HandleKeyEvent(keyEvent);
|
||||
}
|
||||
|
||||
if (focusedWindow is not null && activeInteractWindow is null)
|
||||
if (focusedWindow is not null)
|
||||
{
|
||||
DispatchMouseEvents(focusedWindow, pointerPosition);
|
||||
}
|
||||
|
||||
wasLeftButtonDown = leftButtonDown;
|
||||
wasRightButtonDown = rightButtonDown;
|
||||
wasMiddleButtonDown = middleButtonDown;
|
||||
|
||||
CanvasRenderSource.CompositeAndDisplay(canvas, pointerPosition);
|
||||
|
||||
lastPointerPosition = pointerPosition;
|
||||
|
||||
Reference in New Issue
Block a user