Generic handlers with arguments
Is it possible to create a somewhat generic handler within remote.lua which could handle a few simple arguments ? Then within layout.xml, I could call the same function (handler) with slightly different arguments ? The arguments would be the key that I would like to send.
if /elseif, variables etc. Check out FFI for more exotics.
Most things LUA.
Пвел Тяско 00
Here's a bit more detail on what I'm trying to do. I'm guessing there's just some sort of fundamental that I'm missing....
This is the example of a button that I'd like to create (within layout.xml)
<button text="Bob" color="yellow" ontap="bobFunction" />
actions.bobFunction = function() kb.stroke("alt", b) end
But I'd really like to do a more generic version of this where I could pass in the key (for example alt-b) that I want to send:
[email protected] k:string this is a key actions.pushKey = function(k) kb.stroke("alt", k) end
Which I'm hoping to call like this (from layout.xml)
<button text="Bob" color="yellow" ontap="pressKey(b)" />
The missing fundamental.... maybe?.....
Each button has a function, and I cannot see how you would enter a different value..... b, k...?... for one button. Where would you enter the different values for the button?
Otherwise, you should look at how the built-in keyboard is implemented (Remotes/Main/Keyboards).
When "Alt" or "Fn" is pressed it waits for the second key input.
All of the logic is in "keyboard.lua".
There is no "layout.xml" file as the "keyboard.lua" file builds the layout when it is called by the "remote.lua" of the chosen language.
You will need to build your remote, with a "layout.xml" and a "remote.lua" and put the necessary logic (derived from the built-in remote.lua) into your new remote.lua, to achieve the key modification.