What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the...

33
Using Virtual Keyboards on Q Jan Arne Petersen, Senior Software Engineer at KDAB

Transcript of What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the...

Page 1: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

UsingVirtualKeyboardsonQtEmbeddedDevices

JanArnePetersen,SeniorSoftwareEngineeratKDAB

Page 2: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Whatisneeded

Whatisneeded p.2

Whatisneeded

WhatisprovidedbyQt

UseQtinputmethodAPIinQtapplications

Page 3: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Whatkindoftextneedstobeinputted?

Whatisneeded p.3

JustsomePINoraWLANpassword

Machinenameorsimplesetup

Fulltextinputforsearchorediting

Supportforbrowser/3rdpartyapplications

Page 4: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Whatkindofembeddeddevice?

Whatisneeded p.4

Whatkindofscreen?

Whathardwarebutton?

Whatotherkindsofinputs?

Page 5: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

WhatisprovidedbyQt

WhatisprovidedbyQt p.5

Whatisneeded

WhatisprovidedbyQtInputMethodAPIQPAplatformsQtVirtualKeyboard

UseQtinputmethodAPIinQtapplications

Page 6: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

WhatisprovidedbyQt

InputMethodAPI p.6

InputMethodAPI

QPAplatforms

QtVirtualKeyboard

Page 7: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QtInputMethodAPI

InputMethodAPI p.7

VirtualKeyboardsareintegratedinQtviatheInputMethodAPI:

QInputMethod-accessvirtualkeyboardfromapplication

QPlatformInputContext-virtualkeyboardside

QInputMethodQueryEvent-sendinformationfromapplicationtovirtualkeyboard

QInputMethodEventandQKeyEvent-sendinputeventsfromvirtualkeyboardtoapplication

Page 8: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

InputMethodsinQt-Overview

InputMethodAPI p.8

Page 9: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

WhatisprovidedbyQt

QPAplatforms p.9

InputMethodAPI

QPAplatforms

QtVirtualKeyboard

Page 10: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QPlatformInputContext

QPAplatforms p.10

VirtualkeyboardsideofAPI

PartofQtPlatformAbstraction

TwokindsofQPlatformInputContextforvirtualkeyboardsNativeprovidedbyplatformCustomviaQPlatformInputContextFactory

Page 11: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

NativeVirtualKeyboards

QPAplatforms p.11

Usesthevirtualkeyboardprovidedbythesystem

SupportedQPAplatforms:androidiosqnxwaylandwindows

Page 12: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

CustomVirtualKeyboards

QPAplatforms p.12

QPlatformInputContextFactory

SupportedQPAplatforms(inQt5.11):bsdfbcocoadirectfb/linuxfbeglfsintegritymirclientvncwaylandwindowsxcb

Page 13: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QPlatformInputContextFactory

QPAplatforms p.13

PluginisdefinedviaQT_IM_MODULE

InputcontextcreationharmonizedinQt5.6null:defaultplatformcontextempty:nocontextset:setone,ifitexistsandisvalid(otherwisenocontext)

1 QStringicStr=QPlatformInputContextFactory::requested();2 if(!icStr.isNull()){3     mInputContext.reset(QPlatformInputContextFactory::create(icStr));4 }else{5     QPlatformInputContext*ctx=newQWaylandInputContext(mDisplay.data());6     mInputContext.reset(ctx);7 }

Page 14: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Wayland

QPAplatforms p.14

Thedefaultplatformcontextusesthekeyboardprovidedbythecompositorviathe"text-input"protocol

Nextofficialversioninwayland-protocolwillbe"text-input-unstable-v3"

WhenusingaQtWaylandcompositorthedefaultcontextforwardstheQtInputMethodAPIfromtheapplicationtothecompositorsothatonecanjustuseanyQPlatformInputContextoncompositorside

Thereisalsothe"input-method"protocolforout-of-processvirtualkeyboards(notsupportedinQtWaylandyet)1 importQtQuick2.02 importQtWayland.Compositor1.134 WaylandCompositor{5 ...6     TextInputManager{7     }89 }

Page 15: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Embeddingkeyboardinapplication

QPAplatforms p.15

Somevirtualkeyboards(likeQtVirtualKeyboard)allowembeddinginanapplication

Especiallyusefulforplatformswithoutmultiplewindowmanagementlikeeglfs

WithpreviouslymentionedpatchitcanbeusedinaQtWaylandcompositortoembedtheQtVirtualKeyboardinthecompositor1 importQtQuick2.52 importQtQuick.VirtualKeyboard2.134 InputPanel{5     id:inputPanel6     visible:active7     y:active?parent.height-inputPanel.height:parent.height8     anchors.left:parent.left9     anchors.right:parent.right

10 }

Page 16: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

EmbeddingkeyboardinQtWaylandcompositor

QPAplatforms p.16

Page 17: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

WhatisprovidedbyQt

QtVirtualKeyboard p.17

InputMethodAPI

QPAplatforms

QtVirtualKeyboard

Page 18: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QtVirtualKeyboard

QtVirtualKeyboard p.18

CommercialandGPL

Forxcbplatformitdisplaysautomaticallyinaseparatewindow

ForotherQPAplatformsitallowsembeddinginapplicationwindow

UsesQML

Supportsmultiplelanguageslike:English,French,German,Russian,Arabic,...

SupportsChinese,JapaneseandKorean

Supportstextcorrection(hunspell)

Supportshandwriting(Lipitoolkit)

Page 19: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QtVirtualKeyboard

QtVirtualKeyboard p.19

QT_IM_MODULE=qtvirtualkeyboard

Page 20: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

QtVirtualKeyboard

QtVirtualKeyboard p.20

Supportsadditionalcommercialengines

KDABworkedtogetherwithMyScriptandTheQtCompanytosupportMyScript’s  handwritinginputtechnologyintheQtVirtualKeyboardfortheQtAutomotiveSuite.

ShouldbeincludedinQt5.11

Page 21: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

MyScriptbackground

QtVirtualKeyboard p.21

ProblemstosolveOvercometheHMIComplexityDecreasetheDriverDistraction

MyScriptataglance19yearsofexpertise120employeeso/w25PhDsand75engineersOver400MusersintheworldOver200valueaddedpartners:OEM,ISVandSystemIntegratorsMillionsofcarsontheroaduseMyScript2007:1stConceptCar(Audi,Tokyocarshow)2010:1stCarontheroadwiththeAudi2013:1stMercedes2014:1stTesla2015:1stPorscheand1stVW2016:1stOEMAutomotiveAppwithVW

Page 22: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

MyScripttechnology

QtVirtualKeyboard p.22

TheMostflexibleenginewithcarefreewritingstylesSupportcursiveLatinwritinginalllanguages

AutomaticspaceinsertionbetweenwordsFlexibleletteralignmentWritewordsorpartofwordsontopofeachotherSameengineandAPIsupporthandwritingrecognitionandkeyboardTransliterationPredictionSpellingcorrection

Supportofupto65languagesforwordrecognition99languagesforcharacter-by-characterrecognition

TodaysupportsallavailablelanguagesoftheQtvirtualkeyboards

Page 23: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

UseQtinputmethodAPIinQtapplications

UseQtinputmethodAPIinQtapplications p.23

Whatisneeded

WhatisprovidedbyQt

UseQtinputmethodAPIinQtapplications

Page 24: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Improvetheuserexperience

UseQtinputmethodAPIinQtapplications p.24

QtinputfieldshavebuiltinsupportfortheinputmethodAPIbuttherearestillwaysforapplicationdeveloperstoimprovetheuserexperiencewithvirtualkeyboards:

DefinepurposeoftextinputfieldsAlterapperanceofReturnkeyChangeUIdependingonkeyboard

Page 25: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Definepurposeoftextinputfields

UseQtinputmethodAPIinQtapplications p.25

Thekeyboardcanchangethelayoutdependingonthepurposeofthetextfield

Forexampleenteringdigits,emails,phonenumbers

Qt::InputMethodHintsenumandQt::ImHintsQt::InputMethodQuery

Forexample:Qt::ImhNone-NohintsQt::ImhHiddenText-TheinputmethodshouldnotshowthecharacterswhiletypingQt::ImhDigitsOnly-OnlydigitsareallowedQt::ImhFormattedNumbersOnly-OnlynumberinputisallowedQt::ImhDialableCharactersOnly-OnlycharacterssuitableforphonedialingareallowedQt::ImhEmailCharactersOnly-Onlycharacterssuitableforemailaddressesareallowed

Multiplehintscanbecombined.Forexampleforpasswordfields:Qt.ImhNoAutoUppercase|Qt.ImhNoPredictiveText|Qt.ImhSensitiveData|Qt.ImhHiddenText

Page 26: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Definepurposeoftextinputfields-example

UseQtinputmethodAPIinQtapplications p.26

1 TextInput{2     id:input34     inputMethodHints:Qt.ImhFormattedNumbersOnly5 }

Page 27: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

AlterapperanceofReturnkey

UseQtinputmethodAPIinQtapplications p.27

CanbeusedtodisplayalternativekeyinsteadofReturn

Qt::EnterKeyTypeenumandQt::ImEnterKeyTypeQt::InputMethodQuery

Forexample:Qt::EnterKeyDone-Showa"Done"buttonQt::EnterKeySend-Showa"Send"buttonQt::EnterKeySearch-Showa"Search"buttonQt::EnterKeyReturn-ShowaReturnbuttonthatinsertsanewlineQt::EnterKeyNext-Showa"Next"buttonwhichshouldbeusedtonavigatetonextinputfield

Notallofthesevaluesaresupportedonallplatforms.Forunsupportedvaluesthedefaultkeywillbeusedinstead.

Future(Qt5.11?):Qt::ImEnterKeyLabelandQt::ImEnterKeyEnabled

Page 28: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

AlterapperanceofReturnkey-Example

UseQtinputmethodAPIinQtapplications p.28

1 TextInput{2     id:input34     EnterKey.type:Qt.EnterKeySearch//Showa"Search"button5 }

Page 29: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

ChangeUIdependingonkeyboard

UseQtinputmethodAPIinQtapplications p.29

Whenavirtualkeyboardisshownitmightoverlapsomepartsoftheapplication

Inparticularnotsonicetooverlapthefocusedinputfield

QInputMethod::visiblepropertycanbeusedtofigureoutifavirtualkeyboardisdisplayed

QInputMethod::keyboardRectanglepropertyholdsthevirtualkeyboard'sgeometryinwindowcoordinates

Page 30: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Questions

p.30

Questions

Page 31: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

MaliitFramework/Keyboard(basedonUbuntuKeyboard)

p.31

OpenSource:LGPL-3

Keyboardrunsinaseparateprocess

UsesQML

Supportsmultiplelanguageslike:English,French,German,Russian,Arabic,...

SupportsChinese,Japanese,Korean

Supportstextcorrectionandprediction

Page 32: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

MaliitKeyboard

p.32

Page 33: What is needed - KDAB€¦ · When a virtual keyboard is shown it might overlap some parts of the application In particular not so nice to overlap the focused input field QInputMethod::visible

Thankyou!

www.kdab.com

[email protected]