[SailfishDevel] Creating advanced keyboard layouts with custom input handlers

Arvid Fahlström Myrman behold at behold.se
Sun Jan 5 16:34:37 UTC 2014


Hi,

I've been trying to experiment with creating more advanced keyboard layouts 
than ones who simply map one key to one character---more along the lines of 
the Chinese pinyin layout. To that end, I've been investigating the relevant 
QML files located in /usr/share/maliit/plugins/com/jolla/, and I think that 
I've got a decent idea of how they work. In essence, I need to create a custom 
input handler that, instead of querying the Xt9 library for potential
candidates, implements its own logic.

However, here I've hit a bit of a snag. Whenever the keyboard is started it
seems to default to the standard InputHandler input handler, but almost 
immediately after starting, as well as (as far as I can tell) every time 
canvas.layoutRow.switchLayout is called, something somewhere changes the input 
handler to the Xt9InputHandler. If the layout is changed to the Chinese pinyin 
layout, though, the Xt9CpInputHandler is used instead, thanks to the magic 
value "china_pinyin" specified in the type attribute of the Chinese keyboard 
layout (zh_cn_pinyin.qml). However, from what I can see there's no 
straightforward way for a layout to specify a custom input handler---the 
Chinese input handler being hard coded.

Am I overlooking something? Is it in fact possible to tell the keyboard to 
switch to a specified input handler upon loading a layout? If not, is it 
possible to tell the keyboard *not* to switch to the Xt9InputHandler? If I for 
instance try to set keyboard.inputHandler to an InputHandler in the 
Component.onCompleted attribute in en.qml, I can see how the input handler is 
changed for a fraction of a second before being changed again to the 
Xt9InputHandler. And I'm not sure if there's any non-ugly way to make sure 
that my code changing the input handler to my custom handler is instead run 
immediately after the code that switches the handler to the Xt9InputHandler 
has finished running.

As an aside, would it be possible for a custom layout to register itself 
without having to edit layout.conf? That would make it much easier to provide 
the layout in the form of a simple RPM package.

Regards,
Arvid



More information about the Devel mailing list