feat: ungrab cursor w/ typing

This commit is contained in:
Adam Whitehurst 2021-05-16 15:07:43 -07:00
parent 9dcf7a9d26
commit 26dd5671d1

View File

@ -3347,14 +3347,20 @@ impl Hud {
WinEvent::InputUpdate(GameInput::Chat, true) => { WinEvent::InputUpdate(GameInput::Chat, true) => {
self.ui.focus_widget(if self.typing() { self.ui.focus_widget(if self.typing() {
// regrab cursor when done typing
self.force_ungrab = false;
None None
} else { } else {
// ungrab cursor when activating typing
self.force_ungrab = true;
Some(self.ids.chat) Some(self.ids.chat)
}); });
true true
}, },
WinEvent::InputUpdate(GameInput::Escape, true) => { WinEvent::InputUpdate(GameInput::Escape, true) => {
if self.typing() { if self.typing() {
// If we were typing, the cursor was ungrabbed, so regrab it.
self.force_ungrab = false;
self.ui.focus_widget(None); self.ui.focus_widget(None);
} else if self.show.trade { } else if self.show.trade {
self.events.push(Event::TradeAction(TradeAction::Decline)); self.events.push(Event::TradeAction(TradeAction::Decline));