KeyCaps

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

KeyCaps

Post by richmond62 » Sat Feb 02, 2019 8:15 pm

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...

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: KeyCaps

Post by bogs » Sat Feb 02, 2019 10:22 pm

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.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: KeyCaps

Post by richmond62 » 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.

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: KeyCaps

Post by bogs » Sat Feb 02, 2019 11:10 pm

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:
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: KeyCaps

Post by richmond62 » Sat Feb 02, 2019 11:44 pm

The KeyBoard Viewer behaves the same way in macOS.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: KeyCaps

Post by richmond62 » Tue Feb 05, 2019 1:02 pm

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

Pseudocode:

send "keyDown" to (rawKey 35)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: KeyCaps

Post by dunbarx » Tue Feb 05, 2019 6:03 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: KeyCaps

Post by richmond62 » Tue Feb 05, 2019 11:25 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: KeyCaps

Post by dunbarx » Mon Apr 08, 2019 5:30 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: KeyCaps

Post by richmond62 » Mon Apr 08, 2019 7:32 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: KeyCaps

Post by dunbarx » Mon Apr 08, 2019 8:04 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”