Skip to content

Turn .text_input() into an ElementBuilder terminal method #77

Description

@TheRedDeveloper

Summary

Refactor .text_input() from a chainable ElementBuilder modifier method into a terminal method (as an alternative to .children() and .empty()).

Motivation

Currently, .text_input() permits adding non-floating children which does not make sense layout-wise. Turning it into a terminal method allows developers to configure layout modifiers like .padding() directly on the housing element itself and ensures that internal text input components, such as the scrollbar, correctly envelope the entire layout including the padding.

Proposed API

ui.element().id("editor").width(fixed!(400.0)).height(fixed!(120.0))
  .layout(|l| l.padding(12))
  .text_input(|t| t
    .multiline()
    .font_size(24)
  );

Currently, developers must use a boilerplate wrapper element to achieve proper internal padding:

ui.element().width(fixed!(400.0)).height(fixed!(120.0))
  .layout(|l| l.padding(12))
  .children(|ui| {  
    ui.element().id("editor").width(grow!()).height(grow!())
      .text_input(|t| t
        .multiline()
        .font_size(24)
      )
      .empty();
  });

And this still doesn't work properly with the input's scrollbar as that would be limited to the padded off area or with the overflow caused by scrolling.

Behavior

  • Switch to .text_input() to a terminal method (-> Id) on ElementBuilder.
  • Parent element padding configurations dynamically adjust the internal text input bounds.
  • The scrollable area includes the added padding, the padding can thus be scrolled away.
  • The scrollbars extend to include the padded perimeter.
  • The .text_input() does not create a text-input child ghost. It is applied on the actual element it terminates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedA feature that has been approvedfeatNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions