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

Implement a TextInput widget #46

Open
hecrj opened this issue Jun 10, 2019 · 3 comments
Open

Implement a TextInput widget #46

hecrj opened this issue Jun 10, 2019 · 3 comments
Labels
feature New feature or request help wanted Extra attention is needed

Comments

@hecrj
Copy link
Owner

hecrj commented Jun 10, 2019

We need a widget to ask users for text input. This seems to be a highly interactive widget that may pose a real challenge. We could start simple and forget about text selection, copy, cut, paste, etc.

Here are a couple of challenges that I see:

  • Choosing where to place the input cursor based on a mouse click. I am not sure if we will have to contribute additional functionality to glyph-brush to get this working properly.
  • Clipping text when it does not fit inside the input. Maybe we could use a Canvas to emulate it, but it may be tricky with the current Widget API. We may need to change it in order to make rendering more composable.

This is the kind of API I would personally like:

pub enum Message {
    TextChanged(String),
}

let state = &mut text_input::State::new();
let value = String::from("Some text!");

TextInput::new(state, &value).on_change(Message::TextChanged);
@hecrj hecrj added feature New feature or request help wanted Extra attention is needed labels Jun 10, 2019
@hecrj hecrj mentioned this issue Jun 10, 2019
24 tasks
@buxx
Copy link

buxx commented May 10, 2020

I agree with that ! I'm trying to implement one without success ...

@buxx
Copy link

buxx commented May 11, 2020

I'm working on a POC, with very limited features. See here. It is a simple Text which able to send message when "selected" on click. Question: Is it possible to know when a Text is clicked from "user" code (get the layout/bindings in fine) ?

@hecrj
Copy link
Owner Author

hecrj commented May 11, 2020

Hey @buxx,

I implemented a TextInput widget in iced in this PR: iced-rs/iced#37. iced is a standalone crate based on the current ui module in coffee. The widget implementation should be similar between both crates, so you may find the PR useful!

We should eventually use iced for the ui module in coffee. I started working on this in #88, but iced has changed quite a bit since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants