Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IME integration (and a new TextBox widget) #1636

Merged
merged 3 commits into from
Mar 16, 2021

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Mar 5, 2021

This is a big rollup of work on integrating platform text input APIs into druid.

It is based on (and currently includes commits from) #1619. It also includes commits from a number of other smaller PRs, such as #1630, #1634, and #1635.

Input methods

The highlight of this work is that the textbox is now designed to work with platform text input APIs. Currently these are only supported on macOS; there is a very simple shim in place for other platforms, so that they should continue to work as before.

Screen.Recording.2021-03-05.at.4.31.04.PM.mov
Screen.Recording.2021-03-05.at.4.49.44.PM.mov

There are various little bugs to be worked out here (the size of the text seems to jump around, the position of the text isn't always reported correctly) but overall I think it's good enough to merge.

Textbox changes

As this work involved ripping everything out anyway, I decided to overhaul the textbox. In particular the textbox now uses a normal Scroll widget internally to manage text-position, instead of having its own custom clip/hscroll code. A major benefit of this change is that the multi-line textbox is much better; it will grow vertically until it hits a constraint, and once it is constrained it will show sliders:

Screen.Recording.2021-03-05.at.4.59.00.PM.mov

Known issues

My current plan is to get the other PRs merged, rebase this, and get it merged, more or less as-is. This will introduce some bugs, but we can address them individually instead of just trying to cram everything into here.

That said, there are some problems I'm aware of:

  • whitespace measurement on macOS is buggy
  • line height doesn't appear to be correct with some scripts, which means we aren't drawing the composing region correctly
  • composing region and selection region seem to get confused, sometimes
  • empty lines that are included in a selection are not visibly selected
  • we do not always flash the scrollbars when expected, during editing
  • text input behaviour regresses somewhat on linux & windows, because we use a new shim to simulate IME on these platforms, and there's a bunch of things we don't currently handle.

I'm sure more things will crop up over time.

This is a rollup of a bunch of messy work exploring IME integration.

Ime progress: make simple editor widget, do some invalidiation

This doesn't do invalidation when the document changes, but
it does invalidation when the selection changes?

wip getting a little closer?

Add examples/textbox, get multiline and scroll_to working

This adds a new example for displaying textbox config options,
and gets multiline working with a clip view, with scrolling
to display new text on return.

Embed TextBox in a Scroll widget

This now 'just works' with vertical scrolling, only showing
scrollbars when it makes sense.

TextBox text alignment is working again

Manually clip placeholder text in TextBox

Rename types and fixup docs

Textbox scroll fixups

- dragging the selection causes scroll
- only do scroll_to with a larger rect if the target is not
  visible.
This is a rollup of a bunch of checkpoint commits while I was
getting the textboxes working with IME again.

Input editor uses notifications to communicate return/cancel/tab

This lets the widget using the editor to have more control over
behaviour; it also makes it possible to handle return/escape
without breaking an IME session.

Get ValueTextBox working again

This still some issues around invalidation, but it's... *mostly*
working. It feels really fragile.

Delete old textbox impl

TextBox, not component, is responsible for managing focus

This moves to making the component much 'dumber', and lets more
higher-level logic be handled in higher-level widgets.

Communicate invalidation state with the platform.

During event handling, the SharedTextComponent tracks invalidation
state; after update the user of the component checks for this
state and invalidates with the platform if needed.

Only request a cursor timer when we have focus

This fixes a long standing issue any textbox that had ever had
focus would continue requesting timers until the end of time.

Stash external selection changes and apply them when updating text

This fixes an issue where the ValueTextBox would not be able
to determine when the selection had changed during editing.

Fixup tests

Remove old editing code

File and type renames

This tries to move a bunch of types into the right files, and
moves those files into the right modules, with meaningful names.

ValueTextBox moves to value_textbox.rs
ime_textbox.rs moves to textbox.rs
ImeTextBox renamed to TextBox
ImeHandlerRef and TextFieldRegistration moved to text/input_methods.rs
ime_handler.rs moved to input_component.rs
SharedTextComponent -> TextComponent

Fixup broken doc links

Simplify examples/textbox.rs

This also adds menus so we can play with copy/paste etc.

Get paste/copy/cut working again

This gets us back to parity with the current situation, but I'd
like to get these working without menus soon.
- Make invalidate_text_field not take an Option
- Use WidgetWrapper for Padding
- remove some unused code
- Other small doc fixes
- Add TextBox example to web examples
@cmyr
Copy link
Member Author

cmyr commented Mar 16, 2021

Okay I've opened #1652 to track follow-up work, let's see what breaks?

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