Skip to content

Conversation

@IGalat
Copy link

@IGalat IGalat commented Nov 28, 2021

Companion update to Lazy AE2

Copy link
Owner

@phantamanta44 phantamanta44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great work; the "k" thing is a fantastic idea. here are a few concerns:

  • the same concern about enter being used as a navigation key. avoid this
  • the same concern about text boxes auto-committing their changes. this should not be possible
  • the same concern about auto-formatted code
  • you should find some way to define a generic concept of "focusability" for gui components
    • it should encapsulate the means of getting previous/next focus targets and also handle the focus state
    • could be done by a "focusable" interface that gui components can implement
    • once implemented, this should allow you to remove the next-component field from gui components and to avoid hardcoding focusing behaviour for text boxes
  • shift+tab should be usable to navigate backwards through focusable components

return passThrough;
}

private boolean focusFirstTextFieldOnKeys(List<Integer> keys, int keyCode) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the keys parameter for? it can be factored out
(in fact, this whole method can be inlined, since it only has one call site)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it's useless. On extending functionality may come in handy

this.mouseOver = false;
}

public GuiComponent getComp() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be called getComponent

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's auto-generated. Then comp should be called component, but you named it comp

boolean handleKeyTyped(char typed, int keyCode) {
return comp.onKeyPress(keyCode, typed);
boolean success = comp.onKeyPress(keyCode, typed);
if (keyCode == Keyboard.KEY_ESCAPE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want component-level keys and gui-level keys to process at the same time. it might be best to just check the gui-level keys first then skip the component-level keys if needed

private String value;
@Nullable
private final String tooltipKey;
private FieldType fieldType = FieldType.ALL_TEXT;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field type should not be mutable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. It's inconvenient without a builder instead of just constructors though

updateValidity();
onTextCharInput(typed);
} else if (keyCode == Keyboard.KEY_DELETE) {
value = "";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is no good; users expect the delete key to delete the character in front of the cursor. since the cursor cannot be moved here, the delete key must stay nonfunctional. you can perhaps put this behaviour on ctrl+shift+backspace or something

(is it really even necessary? ctrl+backspace should be good enough for most applications, and certainly for a numeric input)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not necessary, but I didn't know about ctrl backpace

value = val;
break;
case ALL_TEXT:
default:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant default case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh

val += typed;
} else if (typed == 107) { // letter "k", add 000 (multiply by thousand) if can
if (val.equals("") || val.equals("0")) {
val = "1000";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ignores length checks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no big deal, it should be invalidated in that case

val += "0";
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also add a case for "m", standing for millions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k k works fine in that case, no need unless you have 10^15 and more

@IGalat
Copy link
Author

IGalat commented Dec 1, 2021

I feel like we have different ideas of what as and isn't fine. I think enter navigation is ok(like in excel, which LM kinda is); auto-commit is a big yes and doing otherwise is very much user hand-holding; auto-format is just convenience.
Otherwise, it's a quick fix of most pressing issues I had, not a great patch or whatever. Thus an ad-hoc focus switch and other things. As I said, feel free to close this and just cherry pick whatever - I'm fine with this version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants