Accordion Functionality
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Accordion Functionality
I'm trying to build in accordion functionality to hide expand/collapse content and reposition the other rows accordingly.
e.g.
Odd Row 1
Even Row 1
Odd Row 2
Even Row 2
Odd Row 3
Even Row 3
I'd like to be able to hide all Even Rows when pushing a button then repositioning the odd rows so that the gaps are filled.
Pushing another button would re-expand the Even Rows (and reposition the Odd Rows accordingly).
Right now, I've been scripting this out row by row but there must be a more efficient way that handles the relationships between odd and even more elegantly.
Any suggestions?
e.g.
Odd Row 1
Even Row 1
Odd Row 2
Even Row 2
Odd Row 3
Even Row 3
I'd like to be able to hide all Even Rows when pushing a button then repositioning the odd rows so that the gaps are filled.
Pushing another button would re-expand the Even Rows (and reposition the Odd Rows accordingly).
Right now, I've been scripting this out row by row but there must be a more efficient way that handles the relationships between odd and even more elegantly.
Any suggestions?
Re: Accordion Functionality
Hi.
There are many ways to do what you want, and you only have to script whatever action might be appropriate once.
Are these lines in a list field? You are already doing this? Can you say how, in broad terms? If it is a field, any reasonable number of lines would be swapped instantly.
Craig Newman
There are many ways to do what you want, and you only have to script whatever action might be appropriate once.
Are these lines in a list field? You are already doing this? Can you say how, in broad terms? If it is a field, any reasonable number of lines would be swapped instantly.
Craig Newman
Re: Accordion Functionality
Andy .... LC CLASSIC ROCKS!
Re: Accordion Functionality
Try this. On a new card, make a field with your test data in it. Make a button, and put this into its script:
There is an initialization required, and I did this with the optionKey gadget. The full contents of the field are stored in a custom property of the field, as well as the even and odd rows in their own custom properties. When you simply click on the button (no optionKey anymore), the two dataSets are alternately loaded. You can always get the original contents back if you need them.
Is that what you were after?
Craig
Code: Select all
on mouseEnter
if the optionkey is down then
get fld 1
set the origContents of fld 1 to it
repeat with y = 1 to the number of lines of it
if y mod 2 = 0 then put line y of it & return after evens
else put line y of it & return after odds
end repeat
set the label of me to "Even" -- or "Odd", if you want, when initializing
set the evenContents of fld 1 to evens
set the oddContents of fld 1 to odds
end if
end mouseEnter
on mouseUp
if the label of me = "Even" then
set the label of me to "Odd"
set the text of of fld 1 to the evenContents of fld 1
else
set the label of me to "Even"
set the text of of fld 1 to the oddContents of fld 1
end if
end mouseUp
Is that what you were after?
Craig
Re: Accordion Functionality
Has anyone seen this: https://livecode.com/elements-accordion/
and if/which LC version it might be in??
cheers
and if/which LC version it might be in??
cheers
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accordion Functionality
I feel that some information was left out there: do you mean in a scrolling list field?hide expand/collapse content and reposition the other rows accordingly
This: https://livecode.com/elements-accordion/
looks like something a bit different as each EXPANDED section is larger than 'just' another line.
AND it is frankly of very little use indeed as it does NOT show how to do that.

-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accordion Functionality
I yaised that prayer no as onie proselytisan effort, mair as an unco shairt text:
"The Lord's Prayer, is the maist kenspeckle prayer in the Christian releegion. It is kent as the Oor Faither an aw (frae the first twa wirds o the prayer) or Pater noster (the Laitin for "Oor Faither")."
https://sco.wikipedia.org/wiki/Lord%27s_Prayer
but I yaised the Inglis vairtie forbye.
- Attachments
-
- Squeeze Box.livecode.zip
- Stack.
- (1.73 KiB) Downloaded 413 times
Last edited by richmond62 on Sun Nov 10, 2024 11:48 am, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accordion Functionality
Code: Select all
on mouseUp
put empty into fld "F2"
put 1 into LYNE
repeat until line LYNE of fld "F1" is empty
put ((line LYNE of fld "F1") & cr ) after fld "F2"
add 2 to LYNE
end repeat
end mouseUp
- Attachments
-
- Button Box.livecode.zip
- Stack.
- (1.2 KiB) Downloaded 557 times
Re: Accordion Functionality
how about:
to hide even numbered lines:
to show all:
Kind regards
Bernd
to hide even numbered lines:
Code: Select all
on mouseUp
repeat with i = 1 to the number of lines of field 1
if i mod 2 is 0 then
set the hidden of line i of field 1 to true
end if
end repeat
end mouseUp
Code: Select all
on mouseUp
set the hidden of line 1 to -1 of field 1 to false
end mouseUp
Bernd
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accordion Functionality
OK: as usual Bernd, you come up with the clever stuff . . . BUT:
AHA:
I really should apologise as Jimmy Shand's bespoke accordion was a Hohner Morino with an 'o'. 
https://youtu.be/-14L7wDwuGc
AHA:
Code: Select all
on mouseUp
repeat with i = 1 to the number of lines of field "F1"
set the hidden of line i of field "F1" to false
end repeat
end mouseUp

https://youtu.be/-14L7wDwuGc
- Attachments
-
- Shand Merino.livecode.zip
- Stack.
- (1.17 KiB) Downloaded 506 times
Last edited by richmond62 on Sun Nov 10, 2024 10:54 pm, edited 1 time in total.
Re: Accordion Functionality
That looks like the Tree View widget. I'm not sure if it is included in all license types but it is an older widget that's been available for a long time.strongbow wrote: ↑Sun Nov 10, 2024 4:40 amHas anyone seen this: https://livecode.com/elements-accordion/
and if/which LC version it might be in??
cheers
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Accordion Functionality
Hmm, thanks Jacque, hadn't thought about styling the tree view, must have a look!
cheers!
cheers!
Re: Accordion Functionality
Hi Alanstrongbow wrote: ↑Sun Nov 10, 2024 4:40 amHas anyone seen this: https://livecode.com/elements-accordion/
and if/which LC version it might be in??
I could not find a widget or anything in LC that resembles the Accordion you linked to.
So I decided to build one:
viewtopic.php?f=9&t=39452
Kind regards
Bernd
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Accordion Functionality
Maybe LiveCode central would like to tell us where it might be found.I could not find a widget or anything in LC that resembles the Accordion you linked to.
Re: Accordion Functionality
[quote=bn post_id=232624 time=1732545171 user_id=1486]
...
So I decided to build one:
viewtopic.php?f=9&t=39452
Kind regards
Bernd
[/quote]
Very nice Bernd, as usual, thanks!
Since you asked about other functionality...:
1. perhaps it'd be nice to be able to expand more than one segment at a time?
2. Could it perhaps deal with any sort of grouped objects as an accordion segment? e.g. if you wanted to place fields + buttons + other controls into one of the groups to show/hide as desired?
Thanks again for your many contributions!!
...
So I decided to build one:
viewtopic.php?f=9&t=39452
Kind regards
Bernd
[/quote]
Very nice Bernd, as usual, thanks!

Since you asked about other functionality...:
1. perhaps it'd be nice to be able to expand more than one segment at a time?
2. Could it perhaps deal with any sort of grouped objects as an accordion segment? e.g. if you wanted to place fields + buttons + other controls into one of the groups to show/hide as desired?
Thanks again for your many contributions!!