Pre-fill EditText box with variable, and update TextView upon changes? #834
Replies: 1 comment 4 replies
-
|
I've tried the following to get my point/question 2 to work: And while this doesn't throw any errors, my terminal simply hangs whenever I try to put any input at all into it and I have to forcibly kill it. Any other solution I've tried either isn't thread safe (RefCell), or is moving each part of my struct that is assigned (var1, var2, etc) by text into the respective child (Just references, any combination of anything short of Arc<RwLock/Mutex>, etc) and thus ensuring that no child has full access to the full struct to pass into the formatting function due to the closure's move. Trying to drop somevar doesn't change anything either, so I'm not sure if it's a deadlock or something unrelated. I'm not sure what else to try at this point. I'm assuming that there's a better approach somewhere, but I'm not finding it right now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want a form with a few EditTexts (user String inputs) with prefilled data based on some variables (we'll call these A), and a final EditText box which dynamically updates whenever the underlying data for the other EditTexts update (should still be editable by the user as normal) (we'll call these B). I've built a partial implementation of this on top of the list_view example (https://github.com/gyscos/cursive/blob/main/cursive/examples/list_view.rs)
but I'm not sure how to pre-fill the data,nor how to update the final EditText whenever the others change. Do I need a callback or something to do this?I've got a function which can handle the logic for changing B whenever the A's update (taking either normal strings or a struct of Strings, and returns a single String), I just need a way to run it when appropriate and somehow use the resulting value and apply it to B.
Also, am I correct that I want to use something like
siv.call_on_name("test", |view: &mut EditView| view.get_content()).unwrap().to_string();to get the data out? It just seems quite complicated for what I'm sure is an extremely common use case.So I guess in summary:
1. How can I pre-fill EditTexts with data from String variables?Nevermind, I found.content()now! I had triedset_content()before but that must be different.2. How can I update the value inside of an EditText based on updates of other EditTexts/Variables? Ie. How can I edit B when any A's change? Am I looking for
.on_edit()to call my function to change the value? But then how would I still update the other variable?3. Is
call_on_namethe correct way to get my data back when I'm ready to pass it from cursive back to my existing control flow?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions