You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a TextEdit and I hope to grab its focus when the key N is pressed. So I wrote the following code. The code is placed in App's update function.
let text_edit = TextEdit::singleline(duration_src)// `duration_src` is a mutable borrow of a `String` stored in the `App` struct.desired_width(100.).hint_text("Music Duration");let out = text_edit.show(ui);if out.response.has_focus(){self.context.edit.key_edit_enabled = false;}else{
ui.input(|i| {if i.key_pressed(Key::N){
out.response.request_focus();}});}if out.response.lost_focus(){ifletOk(duration) = duration_src.parse::<q16>(){self.context.edit.music_duration = duration;}*duration_src = self.context.edit.music_duration.to_string();self.context.edit.key_edit_enabled = true;}
However when running my program and pressed N, the UI freezes. Any other operation has no reaction. And after a few seconds my program crashes with the following message in console:
thread 'main' (15400) panicked at D:\Program Files\Rust\.cargo\registry\src\rsproxy.cn-e3de039b2554c837\epaint-0.33.3\src\mutex.rs:101:17:
DEBUG PANIC: Failed to acquire RwLock write after 10s. Deadlock?
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\eframe_template.exe` (exit code: 101)
So what am I doing wrong in my program? I think this should be a very basic functionality and many programs might require this feature.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a
TextEditand I hope to grab its focus when the keyNis pressed. So I wrote the following code. The code is placed inApp'supdatefunction.However when running my program and pressed
N, the UI freezes. Any other operation has no reaction. And after a few seconds my program crashes with the following message in console:So what am I doing wrong in my program? I think this should be a very basic functionality and many programs might require this feature.
Beta Was this translation helpful? Give feedback.
All reactions