Page 1 of 1

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

Posted: Fri Nov 01, 2019 9:48 am
by dalkin
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

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

Posted: Fri Nov 01, 2019 2:02 pm
by dunbarx
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

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

Posted: Fri Nov 01, 2019 2:29 pm
by dunbarx
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

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

Posted: Fri Nov 01, 2019 2:42 pm
by dunbarx
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

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

Posted: Fri Nov 01, 2019 11:39 pm
by [-hh]
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

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

Posted: Sat Nov 02, 2019 10:30 pm
by bwmilby
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.

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

Posted: Sun Nov 03, 2019 12:43 am
by dunbarx
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