Keyboard access in LCB

Moderators: LCMark, LCfraser

Post Reply
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1808
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Keyboard access in LCB

Post by [-hh] » Tue Jan 30, 2018 1:30 pm

There is an undocumented handler "OnKeypress".
How can it be used?

Or, more general:
Which are the LCB handlers for getting keyboard input?
shiftLock happens

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Keyboard access in LCB

Post by mwieder » Thu Feb 01, 2018 3:32 am

There's an OnKeyPress handler in gradientrampeditor.lcb of the form

public handler OnKeyPress(in pKey as String) returns nothing
# stuff happens here
end handler

Here's the comment from the source for widget.lcb (not much help here):
Name: OnKeyPress
Type: message
Syntax: OnKeyPress <keyText>
Summary: Sent when a key is pressed while the widget has focus.
Parameters:
keyText(string): The key pressed

There's also an OnActionKeyPress handler, but it's not used anywhere at present, and there's no further information about it.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1808
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Keyboard access in LCB

Post by [-hh] » Thu Feb 01, 2018 10:55 am

Thanks Mark.

The OnKeyPress handler in gradientrampeditor.lcb is probably more kind of decoration there as it doesn't even use the parameter.

The description in widget.lcb sounds promising.
But with that there arises at once the question: How to set focus on a widget?
I tried with a timer, no success.

I can't believe that LC Builder is still ignoring the keyboard ...
shiftLock happens

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 285
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Keyboard access in LCB

Post by jameshale » Fri Feb 02, 2018 1:46 am

onFocusEnter
OnFocusLeave
OnKeyPress
OnLayerChanged

the list goes on.

Check out the docs for "com.livecode.widget" in the LCB section of the dictionary.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1808
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Keyboard access in LCB

Post by [-hh] » Fri Feb 02, 2018 2:14 am

James, what a brilliant answer!!

Could you please tell me also which of all these entries gives any help to my questions?
I couldn't find anything to that:

How to get access to the keyboard in LCB?
How to set focus on a widget in LCB?
shiftLock happens

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 285
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Keyboard access in LCB

Post by jameshale » Fri Feb 02, 2018 3:02 am

hmm.

none of the current widgets have text input (that I can see) except for the Android native field and I assume the soon to appear iOS/MacOS native fields.

Both these widgets will employe the FFI to hook into the java or Objective-C libraries which will allow for keyboard entry and, from reading through the Android native field lcb file, selection of keyboard type.

Perhaps this is only way planned?

and yes, I couldn't see a SET focus either.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Keyboard access in LCB

Post by mwieder » Fri Feb 02, 2018 3:38 am

If so, that leaves open the question of how to handle keyboard input / focus events for non-mobile applications.

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 285
Joined: Thu Sep 04, 2008 6:23 am
Location: Melbourne Australia

Re: Keyboard access in LCB

Post by jameshale » Fri Feb 02, 2018 3:41 am

There is a Mac single line field widget in the code base on github.
Currently above my pay grade to fully decipher :?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Keyboard access in LCB

Post by mwieder » Fri Feb 02, 2018 3:58 am

! Good catch - I missed that one when I was searching for KeyPress, because it doesn't use OnKeyPress.

Looks to me like it's taking advantage of callbacks from the NSTextField object. The tests, though, don't do anything with keyboard input or focus, just 'set the text of widget...'.

Post Reply

Return to “LiveCode Builder”