Guithium
Guithium copied to clipboard
keep track of client input inside Textbox
Re-opened from different branch, continuation of #2.
Scope of this PR is to integrate client-side Textbox
with the server.
Whenever client modifies contents of their Textbox
, a packet is sent to the server with an update.
Some parts of code, especially API, was "inspired" by the Slider
element. Implementation relies on NMS EditBox
's responder
field - not entirely sure what is it used for (I can only assume client-side actions) - but generally gets the job done, at least on the first glance.
Following API classes are added:
-
Textbox.OnChange implements QuadConsumer<...>
- Similar toSlider.OnChange
. -
TextboxChangePacket
- Packet containing information aboutTextbox
input field changes. -
TextboxChangedAction
- Action that fires whenTextbox
is changed.
Following API methods are added:
-
Textbox#onChange : OnChange
- GetsOnChange
functional interface associated with thisTextbox
. -
Textbox#onChange(OnChange) : void
- GetsOnChange
functional interface associated with thisTextbox
. - ...above methods are also present on
Textbox.Builder
.
Question and concerns about implementation details:
- Right now,
onChange
is also called when clicking on a field. Looks like vanilla behavior when handlingresponder
. I'm not sure if and what should I do about that.
I tested this PR with the following code.
https://github.com/BillyGalbreath/Guithium/assets/44530932/a14b2b31-a118-403f-a446-c7829c0982bc