Show Truncated list of values and NumProgressBar

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

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

Show Truncated list of values and NumProgressBar

Post by jmburnod » Fri Jul 21, 2017 1:54 pm

Hi All,
i needed one « stShowTruncNumProgress » (others name are welcome) to show progress trough a list of number with progressBar and one truncated list if needs.

I use a function getMyref(nbMax,CurNum)

put getMyref(2134,7) return "1…678…2134" and "7" looks textstyle "Box"
put getMyref(2134,2133) return "1 … 2132 2133 2134" and "2133" looks textstyle "Box"
put getMyref(2134,3)return « 1 2 3 4 … 2134 » and "3" looks textstyle "Box"

We can refresh progressbar and line of numbers with

1. clic on btn "bSetNumElementBar" or type return
2. clic on "…" or a number of numbers line
3. clic on progressbar (this works fine, except that it is not easy to select nbMax if nbMax > 200)
Image
I feel that we can find simpler way to do the same 8)

Here is the stack
Best regards
Jean-Marc
Attachments
stNbPageProgresBar001.livecode.zip
(2.88 KiB) Downloaded 174 times
https://alternatic.ch

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Show Truncated list of values and NumProgressBar

Post by MaxV » Tue Jul 25, 2017 12:25 am

I think that It's better to create 3 different labels, then work on item 2 of center field.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Tue Jul 25, 2017 11:14 am

Hi Max,
Thanks for reply.
I thought the same but using only one fld seems easier. With three labels we have to manage width of each label.
Best regards
Jean-Marc
https://alternatic.ch

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Show Truncated list of values and NumProgressBar

Post by MaxV » Tue Jul 25, 2017 12:57 pm

Well,
then just use (item or word, it depends if you want to use commas to separate numbers)

Code: Select all

lock screen
set the textStyle of word 1 to -1 of field "myField" to "plain"
set the backgroundcolor of  word 1 to -1 of field "myField" to empty
set the textstyle of item 2 of field "myField" to "box"
set the backgroundcolor of  item 2 of field "myField" to orange
unlock screen
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Tue Jul 25, 2017 2:21 pm

Sorry Max,
I was not clear.
Colorising is not a problem.
Did you try the stack ?
The stack contains a large script that i want simplify
https://alternatic.ch

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

Re: Show Truncated list of values and NumProgressBar

Post by [-hh] » Tue Jul 25, 2017 8:56 pm

Hi Jean-Marc,

this is a very nice idea.
You ask for options to shorten the script. Here is a function that may be an option for creating the same truncated text:

Code: Select all

-- x is the current Number, mx is the maximal number
function setNumElementBar x, mx
  if mx <= 10 then return word 1 to mx of "1 2 3 4 5 6 7 8 9 10"
  put max(1,x-1) into x0; put min(mx,x+1) into x1
  put x0 into m
  repeat with i=x0+1 to x1
    put space & i after m
  end repeat
  if x0 > 2 then put "1 ... " before m
  else if x0 > 1 then put "1 " before m
  if x1 < mx-1 then put " ... " & mx after m
  else if x1 < mx then put " " & mx after m
  return m
end setNumElementBar
To avoid the click problems with the graphic, TMHO a scrollbar would be more appropriate. With that you can increase the value by one also at the "ends" by clicking the bar.
To see what I mean, find attached your stack with a changed script of totally < 70 lines (which moreover uses "textChanged" for the "number-input-control").

Hermann
Attachments
stNbPageProgresBar001c.livecode.zip
(2.27 KiB) Downloaded 185 times
shiftLock happens

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Tue Jul 25, 2017 10:20 pm

Hi Hermann,
Thank you
When i coded it I thougt that is a stuff for hh. 8)
I'll leave early tomorow morning. I'll study it tomorrow evening
Jean-Marc
https://alternatic.ch

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Fri Jul 28, 2017 10:22 am

Guten morgen Hermann,
Thanks again, it works fine
I learn a lot each time you suggest something.
I need this for cards "Listes de pictos" and "Mes phrases" of EcrireEnPictos to make more visible the progress between pages

Code: Select all

scrollbar would be more appropriate
Yes. For "ordinary people" whose are able to maintains the mouse button to down and move and good capacity to point with finger for mobile version.
Best regards
Jean-Marc
https://alternatic.ch

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

Re: Show Truncated list of values and NumProgressBar

Post by [-hh] » Fri Jul 28, 2017 5:12 pm

Hi Jean-Marc.

I forgot that you are serving *all* platforms. May be at the end of this year even a HTML5 standalone is (easier) possible for your great (yes, great!) work?

For the current subject I like most your idea to have that field where all displayed numbers (first, prev, current, next, last) are clickable/touchable.
This approach alone is a main tool for going in row forth and back through a list of pictures.
I'll put this into my "object library".

What do you think of using "<<" and ">>" instead of "...", and a mouseDown on these in the field steps faster in direction of the first or last object? Say by stepping -4 down or 4 up respectively?

Hermann
shiftLock happens

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Fri Jul 28, 2017 6:31 pm

Hi Hermann,
What do you think of using "<<" and ">>" instead of "...", and a mouseDown on these in the field steps faster in direction of the first or last object? Say by stepping -4 down or 4 up respectively?
A good suggest again :D
I'll do that.
It should be useful for others and I think to publish it to revOnline.
Do you have an idea how call this stuff ?
Jean-Marc
https://alternatic.ch

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

Re: Show Truncated list of values and NumProgressBar

Post by [-hh] » Fri Jul 28, 2017 6:42 pm

Perhaps "progress field" is a descriptive name?
shiftLock happens

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Sat Jul 29, 2017 1:34 pm

Here is a stack "ProgressField001" with "<<" and ">>" for -4 +4. I add a mousedown to hilite the choosed word and mouserelease script to unhilite choosed word.
Jean-Marc
Attachments
ProgressField001.zip
(2.47 KiB) Downloaded 173 times
https://alternatic.ch

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

Re: Show Truncated list of values and NumProgressBar

Post by [-hh] » Sat Jul 29, 2017 2:09 pm

Hi Jean-Marc.

I like it and it really should be better visible (livecodeshare/revOnline).

One more proposal:
You hard-code the "4". It could also be a local variable tStep or somehow derived from the maximal number (fld "fNumElement") or editable in an additional field?

For example
    put max(3, fld "fNumElement" div 32) into tStep
    put max(3, fld "tStepElement") into tStep

Hermann
shiftLock happens

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

Re: Show Truncated list of values and NumProgressBar

Post by jmburnod » Sat Jul 29, 2017 6:35 pm

Hi Hermann,
You hard-code the "4". It could also be a local variable tStep or somehow derived from the maximal number (fld "fNumElement") or editable in an additional field?
Here is a stack "FieldProgress002" with an editable field "fStep". It seems that is the best way to let the control to the user
Jean-Marc
Attachments
ProgressField002.zip
(2.76 KiB) Downloaded 181 times
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: Show Truncated list of values and NumProgressBar

Post by jameshale » Sun Jul 30, 2017 3:36 am

missing from the max value field...

Code: Select all

on closeField
   set the endvalue of scrollbar "sbCurElement" to me
end closeField
else setting the value here to more than 100 is not reflected in the values of the scroller.

Of course this could be moved to the card script somewhere.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”