Page 1 of 1

KeyCaps

Posted: Sat Feb 02, 2019 8:15 pm
by richmond62
On various Linux distros one has an application called Onboard which has the wonderful
ability to reflect your keyboard layout:

When I use a US English keyboard it looks like this:
-
OB1.png
-
and with a Bulgarian one:
-
OB2.png
-
I cannot work out whether this sort of thing can be recreated in LiveCode...

Re: KeyCaps

Posted: Sat Feb 02, 2019 10:22 pm
by bogs
I suspect you could recreate it, but I think you'd have to know the key-mappings of a heck of a lot of keyboards/languages.

Re: KeyCaps

Posted: Sat Feb 02, 2019 10:44 pm
by richmond62
Onboard does not "know" anyone's key mappings: even if one writes one's
own keyboard layout the thing will pick it up.

It is programmed in Python . . . I suppose I'll have to track down the source code
and try to understand that first, and then . . .

Re: KeyCaps

Posted: Sat Feb 02, 2019 11:10 pm
by bogs
richmond62 wrote:
Sat Feb 02, 2019 10:44 pm
Onboard does not "know" anyone's key mappings: even if one writes one's
own keyboard layout the thing will pick it up.
I guess 'key-mapping' doesn't translate to 'key-layout' well, but I'll give it another shot. Not all keyboards are 'querty', or 'dvorak' mapped. Aside from that, you'd have to know how the keys are mapped to the language. The OS itself will give you the layout the user chose (either at setup or at any other point), but that generally doesn't mean your home free.

An excerpt from Onboards site:
Selection_001.png
Just saying...
Aside from that being a 'custom' layout, I am pretty sure all the ones included were coded as well.

Of course, I could be completely off.

*Edit - or maybe not :wink:

Re: KeyCaps

Posted: Sat Feb 02, 2019 11:44 pm
by richmond62
The KeyBoard Viewer behaves the same way in macOS.

Re: KeyCaps

Posted: Tue Feb 05, 2019 1:02 pm
by richmond62
I wonder if there is a way to fake a keyDown programmatically?

Pseudocode:

send "keyDown" to (rawKey 35)

Re: KeyCaps

Posted: Tue Feb 05, 2019 6:03 pm
by dunbarx
Hi.

"KeyDown" is just a message. Make a field and a button, and put this into the button script:

Code: Select all

on mouseUp
   send "keyDown 3" to fld 1
end mouseUp
Put this into the field script:

Code: Select all

on keyDown tkey
  put tkey after me
end keyDown
Craig Newman

Re: KeyCaps

Posted: Tue Feb 05, 2019 11:25 pm
by richmond62
I know keyDown is just a message: I've been depending on it for 9 years with my Devawriter Pro.

Hence my use of the word "pseudocode".

Unfortunately LiveCode appears to be 'deaf' to whatever else is going on in an operating system;
or at least insofar as it cannot tell me what character will end up in a field if I hit a certain key
on my keyboard without my actually hitting the thing.

Re: KeyCaps

Posted: Mon Apr 08, 2019 5:30 pm
by dunbarx
ReOpening this after two months.

@Ricmond:
I wonder if there is a way to fake a keyDown programmatically?

Pseudocode:

send "keyDown" to (rawKey 35)
You and Bogs have discussed keyboard "mapping. If I understand your original question, why would this not work in a field script:

Code: Select all

on keyDown tKey
   put remap(tkey) after me
end keyDOwn

function remap tKey
  switch tKey
    case "a"
      return "b"
      break
    case "b"
      return "c"
      break
      ...
    
end remap
You need do this only once for each keyboard mapping.

Craig

Re: KeyCaps

Posted: Mon Apr 08, 2019 7:32 pm
by richmond62
Craig, that's a thought, but it would involve a full routine for every possible keyboard mapping . . .

The problem is how (if at all) a stack, on loading, can detect the end-user's key-mapping.

For the sake of argument . . . imagine a stack containing a virtual keyboard where
each 'key' is a field, and when the end-user opens that stack each field contains
the symbol relevant to the end -user's standard key-mapping . . .

This is a way to circumvent an end-user having to press each key on his/her keyboard so the stack
can work out the key-mapping.

One of the ways this could be done were if LiveCode could send a fake keyDown to the OS, and the OS
would 'echo' the relevant key to LC.

Re: KeyCaps

Posted: Mon Apr 08, 2019 8:04 pm
by dunbarx
Richmond.
. imagine a stack containing a virtual keyboard where
each 'key' is a field, and when the end-user opens that stack each field contains
the symbol relevant to the end -user's standard key-mappin
Doesn't this involve the same amount of work, in that a unique "table" must be created for each and every map?

I never thought that the hard coded routine above would be the right way to implement the map. An array stored as a custom property of the stack is the way to do that. And yes, you must create a new array for each "translation". But at least the reverse map comes for free.

Craig