Skip to content

Commit

Permalink
✨ Add tab + enter on login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbreiz committed Mar 20, 2024
1 parent 86054f3 commit 0ae5686
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SRC/Aura_OS/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Aura_OS
{
public class VersionInfo
{
public static string revision = "150320241526";
public static string revision = "200320241245";
}
}
29 changes: 25 additions & 4 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Components/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ public override void HandleLeftClick()
}
}

public override void Update()
public void Update(KeyEvent keyEvent)
{
base.Update();

if (_isSelected)
{
KeyEvent keyEvent = null;

while (Input.KeyboardManager.TryGetKey(out keyEvent))
if (keyEvent != null)
{
switch (keyEvent.Key)
{
Expand Down Expand Up @@ -106,6 +104,22 @@ public override void Update()
}
}

public override void Update()
{
base.Update();

if (_isSelected)
{
if ((DateTime.Now - _lastCursorBlink).TotalMilliseconds > _cursorBlinkInterval)
{
_cursorVisible = !_cursorVisible;
_lastCursorBlink = DateTime.Now;

MarkDirty();
}
}
}

private void HandleLeftArrow()
{
if (_cursorPosition > 0)
Expand Down Expand Up @@ -317,5 +331,12 @@ private void AdjustScrollOffsetToEnd()
{
_scrollOffset = Math.Max(0, Text.Length - (Width / Kernel.font.Width) + 1);
}

public void SetSelected(bool selected)
{
_isSelected = selected;
_cursorVisible = selected;
MarkDirty();
}
}
}
36 changes: 36 additions & 0 deletions SRC/Aura_OS/System/Graphics/UI/GUI/LoginScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Aura_OS.System.Security;
using Aura_OS.System.Users;
using Aura_OS.System.Utils;
using Cosmos.System;

namespace Aura_OS.System.Graphics.UI.GUI
{
Expand Down Expand Up @@ -51,6 +52,41 @@ public override void Update()
{
base.Update();

KeyEvent keyEvent = null;

while (Input.KeyboardManager.TryGetKey(out keyEvent))
{
switch (keyEvent.Key)
{
case ConsoleKeyEx.Tab:
if (Kernel.MouseManager.FocusedComponent.Equals(_username))
{
Kernel.MouseManager.FocusedComponent = _password;
_username.SetSelected(false);
_password.SetSelected(true);
}
else if (Kernel.MouseManager.FocusedComponent.Equals(_password))
{
Kernel.MouseManager.FocusedComponent = _username;
_password.SetSelected(false);
_username.SetSelected(true);
}
else
{
Kernel.MouseManager.FocusedComponent = _username;
}
break;
case ConsoleKeyEx.Enter:
_button.Click();
break;
default:
_username.Update(keyEvent);
_password.Update(keyEvent);
break;

}
}

_username.Update();
_password.Update();
_button.Update();
Expand Down
13 changes: 13 additions & 0 deletions SRC/Aura_OS/System/Processing/Applications/EditorApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Aura_OS.System.Processing.Processes;
using Aura_OS.System.Graphics.UI.GUI;
using Aura_OS.System.Graphics.UI.GUI.Components;
using Cosmos.System;

namespace Aura_OS.System.Processing.Applications
{
Expand Down Expand Up @@ -74,6 +75,18 @@ public override void Update()
}
else
{
KeyEvent keyEvent = null;

while (Input.KeyboardManager.TryGetKey(out keyEvent))
{
switch (keyEvent.Key)
{
default:
_fileContentBox.Update(keyEvent);
break;
}
}

_save.Update();
_fileContentBox.Update();
}
Expand Down

0 comments on commit 0ae5686

Please sign in to comment.