User Interface Question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

User Interface Question

Post by rumplestiltskin » Mon May 07, 2018 5:00 am

I have a card with about a half dozen fields. This will be a modal (sheet) substack. The user will tab from field to field entering data. In a few of those fields, there are some limited choices based upon what the user has provided by entering data in earlier fields. As an example:

Field 1 - The user may enter the word "DAY".
Field 2 - Based upon the entry in Field 1, Field 2 should display a popup with a list of the days of the week. The user ideally would arrow up or down and press the Enter (Return on Mac) or Tab key which would accept the entry and tab over to...
Field 3 - where, depending on which day of the week the user chose, some other choice list would present itself.

I can readily see how to change what data should appear (as there are limited choices) but the part I'm having trouble with is how to do it all with the keyboard. I'd like to only require the mouse for the "Cancel" or "Accept" buttons. I've seen this done on Windows (presumably MS Access) but I'd love to see this done with LiveCode if possible.

It does not appear that the various popups and combo boxes are very keyboard-friendly. Ideas and suggestions?

Thanks,
Barry

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

Re: User Interface Question

Post by dunbarx » Mon May 07, 2018 3:40 pm

Hi,

You have to first choose whether or not a menu-type button will do wherever the choice option occurs. in other words, when the subsequent "field" after the user enters "day" is in focus, are the ONLY options for that control a day of the week? In still other words, if so, then that control can be a pullDown menu button instead of a field.

Let us assume so.

The trick is to set the contents of the button to something appropriate, derived from the entry of the previous field. So if "DAY" is entered into the field, then a closeField handler in the card script will load, likely from a custom property, a list of days.

This is done simply by:

Code: Select all

  put the dayList of this cd into btn yourButton
You can have as many properties as you need, all loaded based on the contents of the entry field. This will require some management, and woe if the user misSpells "DAY".

Need more?

Craig Newman
Last edited by dunbarx on Tue May 08, 2018 3:41 pm, edited 1 time in total.

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: User Interface Question

Post by rumplestiltskin » Tue May 08, 2018 12:46 am

But doesn't what you suggest still require the user to operate the mouse in order to make a choice?

I can get the appropriate data into the "subsequent" field/button/whatever, but it appears LC is missing a "drop-down list" (which I think Access has). In HyperCard, I used an XCMD called (something like) "choiceList" so, when tabbing into a field, the choice list appeared and, whichever choice the user made (usually with arrow keys and a "return") ended up in that field.

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

Re: User Interface Question

Post by dunbarx » Tue May 08, 2018 3:11 am

I assume you know that LC has four different styles of button that "drop down".

Is it that you want to both populate the "subsequent" control and also have it automatically pop up with those choices, ready to select?

You still need the mouse to make the selection, unless you want, say, the arrow keys to do the walking for you.

No problem either way, or maybe in some other way, but write back...

Craig

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: User Interface Question

Post by rumplestiltskin » Tue May 08, 2018 6:20 am

dunbarx wrote:
Tue May 08, 2018 3:11 am
snip...Is it that you want to both populate the "subsequent" control and also have it automatically pop up with those choices, ready to select?

You still need the mouse to make the selection, unless you want, say, the arrow keys to do the walking for you.

No problem either way, or maybe in some other way, but write back...

Craig
Yes, no mouse at all until the final "Accept" to dismiss the modal dialog (although having a keyboard shortcut for that, as well, would be great). I know how to populate the control with the necessary data but can't figure out how to make it appear expanded (showing the choice list) when I tab to it. Maybe I'll need to show and hide a list field programmatically? How does this latter method sound? I just want the tab into the subsequent field to trigger the appearance of the list designed for that field (and, if it's a field I make visible, shift the keyboard focus to that field - hmmm...).

Thanks,
Barry

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: User Interface Question

Post by jmburnod » Tue May 08, 2018 10:29 am

Hi Barry,
Here is a quick try
select fld by ArrowKey left/right
select menuitem by ArrowKey Up/Down
confirm your choice or cancel by returnkey
stPopUpByKB.zip
(1.61 KiB) Downloaded 213 times
Best regards
Jean-Marc
https://alternatic.ch

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

Re: User Interface Question

Post by dunbarx » Tue May 08, 2018 3:38 pm

I think what the OP really wants is this:

On a new card place a field and a pullDown menu button. In the card script:

Code: Select all

on tabKey
   if fld 1 = "day" then put "Mon" & return & "Tue" & return & "Wed" into btn 1
   else if fld 1 = "fruit" then put "Pear" & return & "Apple" & return & "Peach" into btn 1
   click at the loc of btn 1
end tabKey
Type into the field, either "day" or "fruit". Tab out of the field. Now use the U/D arrowKeys to select an option.

I have the handler in the card script, so that multiple fields will fire. But you will need to discriminate among them by analyzing the "target" to see which field has been tabbed out of, so the handler can click on the appropriate pullDown. And you can use "target" (the contents of the target) to see what text has been entered.

Again, the information loaded ought to reside in custom properties:

Code: Select all

if target = "day" then set the text of btn "appropriateButton" to the dayList of this card
There are surely a few more housekeeping chores to make this really clean. And why not challenge yourself to allow the arrowKeys to cycle continuously through the menu list?

Craig
Last edited by dunbarx on Wed May 09, 2018 3:52 pm, edited 3 times in total.

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: User Interface Question

Post by rumplestiltskin » Tue May 08, 2018 3:47 pm

jmburnod wrote:
Tue May 08, 2018 10:29 am
Hi Barry,
Here is a quick try
select fld by ArrowKey left/right
select menuitem by ArrowKey Up/Down
confirm your choice or cancel by returnkey
stPopUpByKB.zip
Best regards
Jean-Marc
Yes; that seems to be very close to what I need. Probably will have to tweak the card script a bit to make it conform to the UI I need (automatically tab to the next field when the previous field's choice is chosen with the Return key) but, essentially, this is what I was hoping for. Many thanks for your efforts! I did not think about the popup menu for this task; it makes perfect sense.

Thanks,
Barry

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: User Interface Question

Post by jmburnod » Tue May 08, 2018 6:48 pm

Welcome Barry
That was a pleased to work with someone from the other side of Pecos River
Jean-Marc from de east of the Pecos :D
https://alternatic.ch

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

Re: User Interface Question

Post by jameshale » Wed May 09, 2018 1:10 am

Have you looked in the dictionary at the following terms:
tabGroupBehavior, focus
And of course the entries ‘related’ to these terms.

You might find your answer there.

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

Re: User Interface Question

Post by dunbarx » Wed May 09, 2018 2:58 pm

Barry.

Did you make the experiment of about four posts above? All that you need, I think, is there.

Let me know if I am still not getting it.

Craig

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: User Interface Question

Post by rumplestiltskin » Wed May 09, 2018 4:47 pm

I haven't yet had a chance to fool around much with Jean-Marc's stack although I can see that it is essentially the solution I need. I'll need to add a bit of code so that accepting the choice in a field will move the focus to the next field until the last field's choice has been done. Then a mouseClick on the "Accept" button will trigger the handler to gather the choices in global vars, dismiss the modal dialog, and update the card (in the main stack).

Using a menu popup in such a programmatic fashion and not as an actual menubar never occurred to me. D-oh!

The goal of this is to make my app use as little of the mouse as possible. My target is an old DOS-based app and the mouse only slows things down.

Many thanks to everyone!

Barry

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: User Interface Question

Post by jmburnod » Wed May 09, 2018 5:39 pm

Hi Barry,
I'll need to add a bit of code so that accepting the choice in a field will move the focus to the next field until the last field's choice has been done
It seems you just have to add " arrowkey right " at the end of menupick message

Code: Select all

on menupick pItemName
   get char 7 to -1 of the short name of the target
   if pItemName = "Cancel" then exit menupick
   put pItemName into fld ("fText" & it) 
   arrowkey right --•• add jmb002
end menupick
Best regards
Jean-Marc
https://alternatic.ch

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

Re: User Interface Question

Post by dunbarx » Wed May 09, 2018 6:07 pm

It is one of the pleasures of LC that the user can interface with controls in unusual ways. That there is a way to have a handler click on a menu button and have that action perfectly simulate a physical mouse click is, well, adorable.

And powerful. You can avoid using the mouse entirely if you want to.

As for moving focus to various places, that can all be done under script control, sequentially or in any other way, managed in a single card handler. If you make my experiment, try to expand it with three fields and three menu buttons, all directed by the target and "target".

Craig

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: User Interface Question

Post by rumplestiltskin » Thu May 10, 2018 11:33 pm

Strange results.
- If I mouseClick on each field, everything works.
- If I use the arrowKey to move from field to field, everything works.

However, if the mouse pointer is outside of the stack window (and I use the keyboard arrows), it fails with an error:

Code: Select all

card "cPopUpByKB001": execution error at line 9 (subwindow: can't find stack or button), char 36
...then, when I click in that script window, the popup menu actually appears when I click on the blue "stop" button at the top of the script window (but only when I click there and, of course, I do have to click there to get back to my stack).

Here's the handler:

Code: Select all

on defTextMU
   get char 6 to -1 of the short name of the target
   if there is a btn ("bMyPop" & it)  then
      popup btn ("bMyPop" & it) at the loc of the target -- [i]this is the offending line[/i]
   end if
end defTextMU
Sometimes I even see the popup menu appearing in the IDE toolbar (if the mouse pointer is over there). I've tried changing the offending line to:

Code: Select all

      popup btn ("bMyPop" & it) at the loc of field ("fText" & it)
...but that didn't change anything.

I can't understand why LC seems to think "the target" is the mouseLoc.

Barry

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”