From 0df584d09a1e9f029fae091266a0e559a2a2add4 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 7 Feb 2021 12:29:30 +0000 Subject: [PATCH] Don't crash if keyboard controls are invoked too soon Fixes #1896 --- internal/driver/gomobile/keyboard.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/driver/gomobile/keyboard.go b/internal/driver/gomobile/keyboard.go index 967878b218..d41435754d 100644 --- a/internal/driver/gomobile/keyboard.go +++ b/internal/driver/gomobile/keyboard.go @@ -8,12 +8,21 @@ import ( func showVirtualKeyboard(keyboard mobile.KeyboardType) { if driver, ok := fyne.CurrentApp().Driver().(*mobileDriver); ok { + if driver.app == nil { // not yet running + fyne.LogError("Cannot show keyboard before app is running", nil) + return + } + driver.app.ShowVirtualKeyboard(app.KeyboardType(keyboard)) } } func hideVirtualKeyboard() { if driver, ok := fyne.CurrentApp().Driver().(*mobileDriver); ok { + if driver.app == nil { // not yet running + return + } + driver.app.HideVirtualKeyboard() } }