I'm pretty sure it can't be done but just checking.

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

Post Reply
dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

I'm pretty sure it can't be done but just checking.

Post by dalkin » Fri Nov 01, 2019 9:48 am

I'm working on a music type app which concentrates on the development of lyrics, not music, and I'm happy with all the text stuff etc. It works by cloning cards as new projects and putting the titles of the project into a scrolling field where a user can navigate to the project etc. etc. All the controls for manipulating everything is contained in the master card that gets cloned. But the desire to add some limited musical functionality has crept in (sound of sad violin).

I've settled on a simple label object eg. 'A' in screenshot (that strums a guitar chord on mouseDown) and to create multiple instances, are cloned. Target distribution is to experienced musicians so no chord diagrams are necessary.

on mouseDown
play GA.aif
grab me
end mouseDown

on mouseDoubleDown
clone me
set the loc of me to "756,301" ## keeps it clear of the other chords, kinda like a drop zone
end mouseDoubleDown

The 'grab' me was included to allow a user to drag it over a scrolling text field where the lyrics are double-line spaced and the 'clone' script is working as expected ie. there are multiple instances of a single chord that plays the .aif when mouseDown(ed) but they are 2 separate objects and if the text field scrolls, the chord doesn't move. I've done a fair bit of searching but I can't seem to find a way to "bind" the chord to its position in the text.

The 'loc' command is a bit messy too because the 'master' object dutifully puts the cloned object into position 'loc' but because it's now populated with the cloned object can't go to the 'loc' so skips a few pixels down and to the right instead.

A small particle of lead behind my left ear might put me out of my misery.
Screen Shot 2019-11-01 at 6.53.47 pm.png
If we're treading on thin ice, well you might as well dance.

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

Re: I'm pretty sure it can't be done but just checking.

Post by dunbarx » Fri Nov 01, 2019 2:02 pm

Hi.

If i understand your issue, why not put a "scrollBarDrag" handler in the scrolling field, and set the vLoc of the draggable field to track?

Also, you want to use the largest caliber, not the smallest.

Craig

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

Re: I'm pretty sure it can't be done but just checking.

Post by dunbarx » Fri Nov 01, 2019 2:29 pm

I made a small test stack. It has a scrolling field named "xxx" with many lines, and a single word in each line. One of the lines near the middle is "hhh". I made a small label field (field 2) and placed it inside the scrolling field. I explicitly set the textHeight of the scrolling field to 16. This is in the script of the scrolling field:

Code: Select all

on scrollbarDrag
   set the top of fld 2 to the top of me + (lineOffSet("hhh",fld "xxx") * the textHeight of fld "xxx"\
          - the scroll of fld "xxx") - the textHeight of fld "xxx" * 2
end scrollbarDrag
The label field tracks the line containing "hhh" when you scroll.

Craig

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

Re: I'm pretty sure it can't be done but just checking.

Post by dunbarx » Fri Nov 01, 2019 2:42 pm

Me again.

Of course you will have to do some clean-up, especially when the line of interest scrolls out of sight; the tracking label field must be hidden in that situation. There might just be other things that are needed to make this work the way you like it. And all this assuming I understood your original point.

Craig

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

Re: I'm pretty sure it can't be done but just checking.

Post by [-hh] » Fri Nov 01, 2019 11:39 pm

Yet another possibility is the following if you want a really simple solution.

Use a monospaced font (e.g. Monaco) for the field and type the "chord"-chars where you wish to have them, for example

Code: Select all

A       E7   D
This is some sample text. Don't
        A
sing it too fast.
Use ONE textsize only so that the spacing is not disturbed.
You could use colors instead, for example

Code: Select all

repeat with i=1 to (the num of lines of fld "out") div 2
   set foreColor of line 2*i-1 of fld "out" to "blue"
end repeat
shiftLock happens

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: I'm pretty sure it can't be done but just checking.

Post by bwmilby » Sat Nov 02, 2019 10:30 pm

It actually sounds like you need ChordPro functionality. That stores chords inline in a text format. Then there are programs that render it with chords over lyrics.

Monospaced font is the easiest way though, you just end up with a bunch of spaces and when you edit lyrics the chords don’t move automatically.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

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

Re: I'm pretty sure it can't be done but just checking.

Post by dunbarx » Sun Nov 03, 2019 12:43 am

but they are 2 separate objects and if the text field scrolls, the chord doesn't move. I've done a fair bit of searching but I can't seem to find a way to "bind" the chord to its position in the text.
I guess I missed this completely. It is not at all about having a control track a particular line as a field scrolls vertically?

Craig

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”