Guithium icon indicating copy to clipboard operation
Guithium copied to clipboard

keep track of client input inside Textbox

Open Grabsky opened this issue 1 year ago • 0 comments

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 to Slider.OnChange.
  • TextboxChangePacket - Packet containing information about Textbox input field changes.
  • TextboxChangedAction - Action that fires when Textbox is changed.

Following API methods are added:

  • Textbox#onChange : OnChange - Gets OnChange functional interface associated with this Textbox.
  • Textbox#onChange(OnChange) : void - Gets OnChange functional interface associated with this Textbox.
  • ...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 handling responder. 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

Grabsky avatar Jul 20 '23 10:07 Grabsky