Skip to content

Commit

Permalink
fix(TScriptForm): read notes
Browse files Browse the repository at this point in the history
- BioHash sleep toggle was made clearer
- BioHash sleep toggle now works saves it's setting properly and had some bugs fixed
- Sleep length (and every "float field") now allows backspace and '.'
  • Loading branch information
Torwent committed Oct 29, 2024
1 parent b682736 commit 6d7398f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions utils/forms/formutils.simba
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,22 @@ This numbers can be Ints or Doubles.
*)
procedure TComponent.NumberField({$H-}sender: TObject;{$H+} var key: char);
begin
if not (key in ['0'..'9']) then
key := #0;
if not (key in ['0'..'9', #8]) then key := #0;
end;

procedure TComponent.FloatField({$H-}sender: TObject;{$H+} var key: char);
procedure TComponent.FloatField(sender: TObject; var key: char);
begin
if not (key in ['0'..'9', #8, '.']) then
key := #0;
case key of
'0'..'9', #8: ;
'.': if TCustomEdit(sender).getText().Contains('.') then key := #0;
else key := #0;
end;
end;


procedure TComponent.MailField({$H-}sender: TObject;{$H+} var key: char);
begin
if (key in [' ']) then
key := #0;
if key = ' ' then key := #0;
end;

(*
Expand Down
5 changes: 3 additions & 2 deletions utils/forms/scriptform.simba
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ function TScriptForm.CreateAntibanManager(): TTabSheet;
if edit <> nil then edit.SetText(ToStr(l));
end;

WLSettings.GetObject('antiban').getJSONObject('sleep').Put('biohash', checked);
WLSettings.SaveConfig();
checkbox.SetChecked(checked);
end;
Expand Down Expand Up @@ -1316,7 +1317,7 @@ begin
with useBio do
begin
Create(Result);
SetCaption('Use BioHash');
SetCaption('Use BioHash for sleep');
SetName('ab_sleep_bio');
SetLeft(sleeps.GetLeft() + TControl.AdjustToDPI(5));
SetTop(sleeps.GetBottom() + TControl.AdjustToDPI(5));
Expand Down Expand Up @@ -1350,7 +1351,7 @@ begin
SetTop(sleepHour.GetBottom() + TControl.AdjustToDPI(5));
SetCaption('Sleep length (hours):');
SetName('ab_sleep_length');
Edit.setOnKeyPress(@Edit.NumberField);
Edit.setOnKeyPress(@Edit.FloatField);
Edit.setOnChange(@Self._SleepLengthOnChange);

SetText(ToStr(Antiban.GetSleepLength()));
Expand Down

0 comments on commit 6d7398f

Please sign in to comment.