Tinderbox Forum

How to make translucent via Stamp or OnAdd or?

I’d like to create an easier mechanism than engaging the inspector to making notes translucent, but a search for the phrase on the aTbRef doc turns up nothing. What’s the name of this attribute/setting and what sort of values does it take?

Thanks,
Beck

$Opacity controls transparency. The “Translucent” checkbox in the Appearance Inspector sets $Opacity to 50%. Range for $Opacity is usually 0 to 100.

2 Likes

There are 9 opacity-related attributes in addition to $Opacity. Some such as $TitleOpacity and $SubtitleOpacity are independent of $Opacity. However, the if higher than the value of $Opacity, the latter value is used when drawing the note.

So, you may need to experiment a little depending on your exact need. Suffice it to say, the variations above arose out of user testing where it became apparent that a one-size-affects-all opacity setting was not optimal.

and one option might be to express those attribute settings in a script, and assign a keystroke to it in something like Keyboard Maestro:

e.g.

Make selected notes transparent.kmmacros.zip (10.6 KB)

JS source
(() => {
    'use strict';

    const main = () => {
        const adjustedTransparency = note => {
            const attributes = note.attributes;

            // Attribute values updated here:

            attributes.byName('Opacity').value = 50;
            // attributes.byName('TitleOpacity').value = 100;
        };

        const documents = Application('Tinderbox 8').documents;
        return either(alert('Tinderbox 8 transparency'))(x => x)(
            bindLR(
                0 < documents.length ? (
                    Right(documents.at(0).selections)
                ) : Left('No documents open in Tinderbox 8')
            )(selections => {
                const intSelections = selections.length;
                return 0 < intSelections ? (
                    selections().forEach(

                        adjustedTransparency
                    ),
                    Right(
                        'Transparency updated in ' +
                        str(intSelections) + ' notes.'
                    )
                ) : Left('Nothing selected in Tinderbox 8.')
            })
        );
    };

    // JAVASCRIPT FOR AUTOMATION --------------------------

    // alert :: String -> String -> IO String
    const alert = title => s => {
        const
            sa = Object.assign(Application('System Events'), {
                includeStandardAdditions: true
            });
        return (
            sa.activate(),
            sa.displayDialog(s, {
                withTitle: title,
                buttons: ['OK'],
                defaultButton: 'OK'
            }),
            s
        );
    };

    // GENERIC FUNCTIONS ----------------------------------
    // https://github.com/RobTrew/prelude-jxa

    // Left :: a -> Either a b
    const Left = x => ({
        type: 'Either',
        Left: x
    });

    // Right :: b -> Either a b
    const Right = x => ({
        type: 'Either',
        Right: x
    });

    // bindLR (>>=) :: Either a -> (a -> Either b) -> Either b
    const bindLR = m => mf =>
        undefined !== m.Left ? (
            m
        ) : mf(m.Right);

    // either :: (a -> c) -> (b -> c) -> Either a b -> c
    const either = fl => fr => e =>
        'Either' === e.type ? (
            undefined !== e.Left ? (
                fl(e.Left)
            ) : fr(e.Right)
        ) : undefined;

    // str :: a -> String
    const str = x => x.toString();

    // MAIN ---
    return main();
})();
1 Like

Stamps are quickly written and appear in the Tinderbox > Stamps menu so it’s very easy to assign a keyboard shortcut via System Preferences.

2 Likes

Indeed. Frustratingly, we are trying to just do the ‘obvious’ task at hand. But, my remembrance is that in different contexts you need a slightly different mix of transparent objects: the ‘body’, the title and/or subtitle, and the border.

Once you know the transparent elements you want a stamp is probably the easiest solution to implement.

This is very helpful advice, thank you!

I realized the Stamps are easily accessible from the menu, but hadn’t made the connection that I could use KM to invoke them.