mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
small refactor per code review
This commit is contained in:
parent
8194c19647
commit
aeae94d31b
@ -195,7 +195,7 @@ impl PendingTrade {
|
||||
self.accept_flags = [false, false];
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
Decline => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3893,17 +3893,16 @@ impl Hud {
|
||||
scale_mode
|
||||
}
|
||||
|
||||
/// Checks if a TextEdit widget has the keyboard captured.
|
||||
fn typing(&self) -> bool { Hud::_typing(&self.ui.ui) }
|
||||
|
||||
/// reusable function, avoids duplicating code
|
||||
fn _typing(ui: &conrod_core::Ui) -> bool {
|
||||
/// Checks if a TextEdit widget has the keyboard captured.
|
||||
fn typing(&self) -> bool { Hud::is_captured::<widget::TextEdit>(&self.ui.ui) }
|
||||
|
||||
/// Checks if a widget of type `W` has captured the keyboard
|
||||
fn is_captured<W: Widget>(ui: &conrod_core::Ui) -> bool {
|
||||
if let Some(id) = ui.global_input().current.widget_capturing_keyboard {
|
||||
ui.widget_graph()
|
||||
.widget(id)
|
||||
.filter(|c| {
|
||||
c.type_id == std::any::TypeId::of::<<widget::TextEdit as Widget>::State>()
|
||||
})
|
||||
.filter(|c| c.type_id == std::any::TypeId::of::<<W as Widget>::State>())
|
||||
.is_some()
|
||||
} else {
|
||||
false
|
||||
|
@ -599,7 +599,11 @@ impl<'a> Trade<'a> {
|
||||
.graphics_for(state.ids.amount_open_btn)
|
||||
.set(state.ids.amount_open_ovlay, ui);
|
||||
} else if let Some(key) = &mut self.show.trade_amount_input_key {
|
||||
if selected.is_some() || (!Hud::_typing(ui) && key.input_painted) {
|
||||
if selected.is_some()
|
||||
|| (!Hud::is_captured::<widget::TextEdit>(ui) && key.input_painted)
|
||||
{
|
||||
// If the user has selected an item, or if the text edit is not captured, then
|
||||
// we can close the text edit.
|
||||
event = Some(Err(HudUpdate::Clear));
|
||||
}
|
||||
key.input_painted = true;
|
||||
|
Loading…
Reference in New Issue
Block a user