give user keyboard option instead of clicking
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: give user keyboard option instead of clicking
Are you on Windows or Mac or Linux? The traversalOn property gives a bit different behaviour on each, according to the O/S provider's standards. On Windows a button with traversalOn set to true will be highlighted when navigating the page by the tab key and will be "pressed" if the user hits the spacebar while it has highlight. I believe Linux does something somewhat similar, but not sure. I don't think Mac behaves the same.
Best to try to make sure your application behaves in the way users of the platform expect.
Best to try to make sure your application behaves in the way users of the platform expect.
-
- VIP Livecode Opensource Backer
- Posts: 7241
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: give user keyboard option instead of clicking
Most web pages use the tab-enter shortcut too. That's what I was thinking about when I asked to see the screenshot. Macs can be set up to behave the same way but it isn't the default so most users don't do it.
If traversalOn is set on the buttons then that may be all that's required. It may need a short script or behavior to catch the enter key, I can't remember. But it would work on Windows, and Mac users wouldn't know the difference.
If traversalOn is set on the buttons then that may be all that's required. It may need a short script or behavior to catch the enter key, I can't remember. But it would work on Windows, and Mac users wouldn't know the difference.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: give user keyboard option instead of clicking
Hi all,
Sorry to say I couldn't get the screenshot to work, yeah, I know, basic stuff - but not something I do often, And I followed the instructions found on Google, but without success. Sorry again - for not being able to run the download richmond62 kindly offered; there is an aberration on my computer that insists I open livecode stuff using version 9.6.9. which has been removed from my computer, as it was causing me other problems and I'm using v.10. So I feel my hands are somewhat tied !
The optionkeydown method looked useful; I tried incorporating the script
Can anyone put me on the right path here?
Oh, I took on board "you SHOULD use the mouse at the end of a process" - actually, the juncture is NOT the end, just another step along the way !
Sorry to say I couldn't get the screenshot to work, yeah, I know, basic stuff - but not something I do often, And I followed the instructions found on Google, but without success. Sorry again - for not being able to run the download richmond62 kindly offered; there is an aberration on my computer that insists I open livecode stuff using version 9.6.9. which has been removed from my computer, as it was causing me other problems and I'm using v.10. So I feel my hands are somewhat tied !
The optionkeydown method looked useful; I tried incorporating the script
but it failed to work - I was guessing how to do it as I couldn't find anything else on the web.answer question "You selected " & fld "cat1" & ". Is this correct?" with "NO" or "YES" titled field "fieldboxtitle" of cd "template1"
if it is "NO" then
answer "Try again. Click on the correct department."titled field "fieldboxtitle" of cd "template1"
exit optionKeyDown theKey
end if
if it is "YES" then
put "cat1" into fld "dept" of cd "doc2"
send "mouseup" to btn "ChangeDescription"
end if
#send "Mouseup" to btn "copytodoc2" of cd "manage products"
#end mouseup
answer numToChar(charToNum(theKey) - 1)
end optionKeyDown
Can anyone put me on the right path here?
Oh, I took on board "you SHOULD use the mouse at the end of a process" - actually, the juncture is NOT the end, just another step along the way !
Re: give user keyboard option instead of clicking
The first line if missing from your script.
But please be a BIT more precise, "it failed to work" is a lousy error description!
So what does not work, the complete script or what?
P.S.
Do not use the QUOTE tags after pasting your script(s) here, use the CODE tags, which looks like this: <>
But please be a BIT more precise, "it failed to work" is a lousy error description!
So what does not work, the complete script or what?
P.S.
Do not use the QUOTE tags after pasting your script(s) here, use the CODE tags, which looks like this: <>
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
CAsba.
You have two parameters, "tKey" and "theKey" and I bet that is what is giving you a problem.
Anyway, I mocked up your handler with a card with some controls on it, substituting for the ones you had. All worked just fine.
Do put your handler into the "Code" tags "</>" not as a "quote". And do include the entire handler if possible.
Craig
You have two parameters, "tKey" and "theKey" and I bet that is what is giving you a problem.
Anyway, I mocked up your handler with a card with some controls on it, substituting for the ones you had. All worked just fine.
Do put your handler into the "Code" tags "</>" not as a "quote". And do include the entire handler if possible.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
CAsba
Looking over your handler again, know that you do not need to:
The "theKey" is ignored. You are simply exiting the "optionKey" handler itself; its parameters are not pertinent.
And because of this, the point I made about two different parameters in my earlier post is also not pertinent, for the same reason. Your handler runs fine, assuming the destination controls that you referenced exist correctly.
Craig
Looking over your handler again, know that you do not need to:
Code: Select all
exit optionKeyDown theKey
And because of this, the point I made about two different parameters in my earlier post is also not pertinent, for the same reason. Your handler runs fine, assuming the destination controls that you referenced exist correctly.
Craig
Re: give user keyboard option instead of clicking
The missing first line is
[/code]on optionKeyDown theKey[/quote]
It failed inasmuch as neither Alt-1 nor Alt-K failed to activate the button.
I have to confess that I don't have much of a clue as to how to proceed with this coding, and the oncepts referred to in some of the comments are way beyond my understanding (which is why I identify as a complete beginner!)
[/code]on optionKeyDown theKey[/quote]
It failed inasmuch as neither Alt-1 nor Alt-K failed to activate the button.
I have to confess that I don't have much of a clue as to how to proceed with this coding, and the oncepts referred to in some of the comments are way beyond my understanding (which is why I identify as a complete beginner!)
Re: give user keyboard option instead of clicking
Hi CAsba,
just made a test on my Mac, and yes the "optionkeydown" message does NOT get sent!?
However "comandkeydown" works fine, maybe you can use that one?
Some hints:
1. This handler needs to be in the card script of the card with the buttons.
2. You should also actually check theKey!
3. If the button "ChangeDescription" contains more than one line of script, you should "outsource" the handler to the card or stackscript!
Example in card script:
Then in the button/commandkeydown handler justexecute that handler:
Capisce?
Best
Klaus
just made a test on my Mac, and yes the "optionkeydown" message does NOT get sent!?
However "comandkeydown" works fine, maybe you can use that one?
Code: Select all
on commandKeyDown tKey
## If you do not check the pressed key, then the handler does not make sense...
if tKey <> "1" then
## This line will leave the handler immediately:
pass commandkeydown
end if
answer question "You selected " & fld "cat1" & ". Is this correct?" with "NO" or "YES" titled field "fieldboxtitle" of cd "template1"
if it is "NO" then
answer "Try again. Click on the correct department."titled field "fieldboxtitle" of cd "template1"
exit commandKeyDown
end if
## No need for another IF THEN, since there is REALLY NO other option! :-)
put "cat1" into fld "dept" of cd "doc2"
send "mouseup" to btn "ChangeDescription"
answer numToChar(charToNum(theKey) - 1)
end commandKeyDown
1. This handler needs to be in the card script of the card with the buttons.
2. You should also actually check theKey!
3. If the button "ChangeDescription" contains more than one line of script, you should "outsource" the handler to the card or stackscript!
Example in card script:
Code: Select all
command buttonclicked_shortcut_pressed
## do this
## and that
## and that over there also
## ...
end buttonclicked_shortcut_pressed
Code: Select all
on mouseup
buttonclicked_shortcut_pressed
end mouseup
Code: Select all
on commandKeyDown tKey
buttonclicked_shortcut_pressed
end commandKeyDown
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
Klaus, CAsba.
The optionKey combination works fine for me. In fact, I always shy away from using the commandKey for this sort of shenanigans since that key is used so ubiquitously elsewhere.
I simply added the missing first line (it was obvious what it was) and, instead of making the distant control destinations that Casba's handler referenced, made a few local controls and substituted them in the handler itself. But doing that would neither have fixed nor broken the underlying flow of the code.
Craig
The optionKey combination works fine for me. In fact, I always shy away from using the commandKey for this sort of shenanigans since that key is used so ubiquitously elsewhere.
I simply added the missing first line (it was obvious what it was) and, instead of making the distant control destinations that Casba's handler referenced, made a few local controls and substituted them in the handler itself. But doing that would neither have fixed nor broken the underlying flow of the code.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
@Klaus.
What platform?? You cut me to the quick. It's the one with the bite taken out of it.
I made a new stack with a field named "cat1" and a button named "ChangeDescription". I did not feel like making and naming new cards. This in the card script:
There is nothing in button "ChangeDescription". But who cares? I get a result from the final answer command. This means that the handler works. I assume that there are issues with the controls referenced with CAsba's setup.
@CAsba
If you place a breakpoint right after the last "answer" line does your handler stop at that point? If so, you have issues as I mentioned. If not, step through the entire handler and report back where LC throws an error.
Craig
What platform?? You cut me to the quick. It's the one with the bite taken out of it.
I made a new stack with a field named "cat1" and a button named "ChangeDescription". I did not feel like making and naming new cards. This in the card script:
Code: Select all
on optionKeyDown tkey
answer question "You selected " & fld "cat1" & ". Is this correct?" with "NO" or "YES" --titled field "fieldboxtitle" of cd "template1"
if it is "NO" then
answer "Try again. Click on the correct department."titled field "fieldboxtitle" of cd "template1"
exit optionKeyDown theKey
end if
if it is "YES" then
put "cat1" into fld 1 --"dept" of cd "doc2"
send "mouseup" to btn "ChangeDescription"
end if
#send "Mouseup" to btn "copytodoc2" of cd "manage products"
#end mouseup
answer numToChar(charToNum(tKey) - 1)
end optionKeyDown
@CAsba
If you place a breakpoint right after the last "answer" line does your handler stop at that point? If so, you have issues as I mentioned. If not, step through the entire handler and report back where LC throws an error.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
CAsba.
Going back to a point Klaus mentioned. You have to see that saying your "handler does not work" is virtually worthless for us. If you read and understand the two small tasks I gave you in the post just above, you should see that this is much more helpful.
For all of us.
Craig
Going back to a point Klaus mentioned. You have to see that saying your "handler does not work" is virtually worthless for us. If you read and understand the two small tasks I gave you in the post just above, you should see that this is much more helpful.
For all of us.
Craig
Re: give user keyboard option instead of clicking
Too funky, tested again today with:
and now it works...
Anyway completely forgot that pressing the option key will result in another character than exspected!
Code: Select all
on optionkeydown tKey
answer tKey
end optionkeydown
Anyway completely forgot that pressing the option key will result in another character than exspected!
-
- VIP Livecode Opensource Backer
- Posts: 9678
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: give user keyboard option instead of clicking
Klaus.
What? How could something not work and then work?? Or even the other way around???
CAsba. So this is now up to you. Your problem is not with your code, it is with something that you are doing elsewhere, likely all about those control references I am on about.
Craig
What? How could something not work and then work?? Or even the other way around???
CAsba. So this is now up to you. Your problem is not with your code, it is with something that you are doing elsewhere, likely all about those control references I am on about.
Craig