Option Menu
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 108
- Joined: Mon Mar 20, 2017 5:13 am
Option Menu
I can correctly get the current year, but need to put the previous years (up to 100) in the format below:
2018
2017
2016
2015
and so on
this data will go into the menu items of the option menu.
I don't know how to put the dates in the format above.
2018
2017
2016
2015
and so on
this data will go into the menu items of the option menu.
I don't know how to put the dates in the format above.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Option Menu
Hi,
This should work
Best regards
Jean-Marc
This should work
Code: Select all
on mouseup
put empty into t
repeat with i = 2018 down to 1918
put i & cr after t
end repeat
delete char -1 of t
set the text of btn "myMenuOption" to t
end mouseup
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
That is an awfully long list. I would recommend that you not do this.
In the US, we are constantly presented with a dropDown of the 50 states when entering addresses for whatever onLine thing we are filling out. It is always a pain, even when one can type the first char of ones state to bring the list to that portion of the overall set.
100 is at least twice as onerous.
A much better way is to allow the user to start typing into a field, and a dropDown appears after, say, the second or third character, filtering out all but those items that match. Now a very short list appears, and the process is actually fun to use.
Need advice?
Craig newman
In the US, we are constantly presented with a dropDown of the 50 states when entering addresses for whatever onLine thing we are filling out. It is always a pain, even when one can type the first char of ones state to bring the list to that portion of the overall set.
100 is at least twice as onerous.
A much better way is to allow the user to start typing into a field, and a dropDown appears after, say, the second or third character, filtering out all but those items that match. Now a very short list appears, and the process is actually fun to use.
Need advice?
Craig newman
Re: Option Menu
What Craig said, bonus it is the basis for a good autocomplete routine as well. Nice.
Re: Option Menu
I think in case of numbers we could trust our users to enter the number into a field, right?
Or provide a field with the number and one of these tiny scrollbars to de-/increase the
initial number in the field.
Or provide a field with the number and one of these tiny scrollbars to de-/increase the
initial number in the field.
Re: Option Menu
Hi Craig -- do you have an example stack of a dropDown field that does what you are describing below? The filtering of the items in a large list to limit choices after a few characters are typed sounds like something useful in many similar cases (like a search).
dunbarx wrote: ↑Sat Jul 21, 2018 2:04 pmThat is an awfully long list. I would recommend that you not do this.
In the US, we are constantly presented with a dropDown of the 50 states when entering addresses for whatever onLine thing we are filling out. It is always a pain, even when one can type the first char of ones state to bring the list to that portion of the overall set.
100 is at least twice as onerous.
A much better way is to allow the user to start typing into a field, and a dropDown appears after, say, the second or third character, filtering out all but those items that match. Now a very short list appears, and the process is actually fun to use.
Need advice?
Craig newman
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
Hi.
On a new card, make two locked fields. Name one "entryField" and the other "selector". Make the height of fld "selector several lines high. Put a long list of any kind into a custom property of fld "entryField" named "contents'". I include a list of the states below if you want to start testing right away. But I would create your own list with many rather similar lines, so that you can see the list adjust as you continue typing and/or deleting chars.
In the script of fld "selector":
In the script of fld "entryField":
You may well want to change the UI here. But for this example, if you click on fld "entryField" and start typing, at the third char any foundLine will appear in fld "selector", along with its following few neighbors.If you backspace, the list will adjust. As you type more and more chars, the field will adjust. You may want to include preceding lines as well, whatever.
Write back with comments and complaints.
Craig
Here are the states.
On a new card, make two locked fields. Name one "entryField" and the other "selector". Make the height of fld "selector several lines high. Put a long list of any kind into a custom property of fld "entryField" named "contents'". I include a list of the states below if you want to start testing right away. But I would create your own list with many rather similar lines, so that you can see the list adjust as you continue typing and/or deleting chars.
In the script of fld "selector":
Code: Select all
on mouseUp
answer the value of the selectedLine
end mouseUp
Code: Select all
local tList
on mouseEnter
hide fld "selector"
put "" into me
put the contents of me into tList
sort tList
end mouseEnter
on rawKeydown tKey
switch
case tKey = 65288
delete the last char of me
if the length of me < 3 then hide fld "selector"
break
case toUpper(tKey) > 96 and toUpper(tKey) < 122 or tKey = 32
put numToChar(tKey) after me
if the length of me > 2 and lineOffset(me,tList) <> 0 then
show fld "selector"
put line lineOffset(me,tList) to lineOffset(me,tList) + 5 of tList into fld "selector"
end if
break
end switch
end rawKeydown
Write back with comments and complaints.
Craig
Here are the states.
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
When you get a chance, perhaps after trying the above gadget, can you winnow out a single result, so that it is not just the line at the top of the list that likely is the line you want, but that when the chars in the entry field have finally defined a single unique "hit", all the others go away?
I am here waiting.
Craig
I am here waiting.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Option Menu
I use variations of the following, which uses a search field for the user to type into, and a results list field that shows matches for whatever the user types. The complete, original list of choices is stored in a cList cutom property of the search field. The handler goes into the search field:
Unless you want the results to always show, this assumes that when the user makes a selection, the searchResults field will hide itself. It also needs to hide if the user clicks outside the field.
The filter will find any match wherever it is in the list lines. If you only want to find matches at the beginning of lines change the filter to:
Edit: I see I've answered a question you didn't ask. Well, maybe this will be useful to someone, sometime, so I'll leave it.
Code: Select all
on textChanged
put the cList of me into tFullList
if me <> empty then
filter tFullList with ("*" & me & "*")
end if
put tFullList & cr into fld "searchResults"
show fld "searchResults"
end textChanged
The filter will find any match wherever it is in the list lines. If you only want to find matches at the beginning of lines change the filter to:
Code: Select all
filter it with (me & "*")
Edit: I see I've answered a question you didn't ask. Well, maybe this will be useful to someone, sometime, so I'll leave it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Option Menu
Jacque.
"Filter" is a bit more modern and likely a bit faster, I think, and just as effective. For me, I do not think, especially in a long list, that anything at all should appear until at least the third char.
Sorting the results is critical when one is zeroing in on the target string, whether done before or after the winnowing.
Craig
"Filter" is a bit more modern and likely a bit faster, I think, and just as effective. For me, I do not think, especially in a long list, that anything at all should appear until at least the third char.
Sorting the results is critical when one is zeroing in on the target string, whether done before or after the winnowing.
Craig