• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Indesign Scripting - BehaviorEvents.MOUSE_EXIT

Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Hi all, I have a question regarding BehaviorEvents.MOUSE_EXIT and BehaviorEvents.MOUSE_ENTER. Is it possible to remove them all using javascript? If this is possible, how do I do this as a newbie?

TOPICS
Scripting

Views

171

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 13, 2021 Dec 13, 2021

Hi David, what you're asking is probably possible, but we'd need more information about your specific needs.

To get started, here's a script I just wrote that will remove behaviors with those event types from all buttons in the active document. I've made it fairly flexible so behaviors can be removed from other items and target different events. Let me know if that works for you.

- Mark

 

/*
    Remove Behaviors
    for Adobe Indesign 2022

    by m1b
    here: https://community.adobe.com/t5/indesig
...

Votes

Translate

Translate
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

What do you mean by 'removing them all'? Remove what? From where?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

LATEST

You are, of course, absolutely right. Sometimes you have the problem in your head and forget that everyone else has not been included in your thoughts so far. I think m1b's answer contains exactly what I was looking for. But he too actually had to guess wildly at my needs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Hi David, what you're asking is probably possible, but we'd need more information about your specific needs.

To get started, here's a script I just wrote that will remove behaviors with those event types from all buttons in the active document. I've made it fairly flexible so behaviors can be removed from other items and target different events. Let me know if that works for you.

- Mark

 

/*
    Remove Behaviors
    for Adobe Indesign 2022

    by m1b
    here: https://community.adobe.com/t5/indesign-discussions/indesign-scripting-behaviorevents-mouse-exit/m-p/12590473
*/


function main() {


    removeBehaviors(

        // remove behaviors from these items:
        app.activeDocument.buttons,

        // remove only behaviors triggered by these events
        [
            BehaviorEvents.MOUSE_ENTER,
            BehaviorEvents.MOUSE_EXIT
        ]

    );


    function removeBehaviors(items, targetEventTypes) {
        if (items == undefined) return;
        if (targetEventTypes == undefined) return;

        // iterate over items
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (!item.hasOwnProperty('behaviors')) continue;
            var behaviors = item.behaviors;

            // iterate over item's behaviors
            behaviorLoop:
            for (var b = behaviors.length - 1; b >= 0; b--) {

                // iterate over array of behaviorEvents to remove
                for (var e = 0; e < targetEventTypes.length; e++) {
                    if (behaviors[b].behaviorEvent == targetEventTypes[e]) {
                        //$.writeln('removing "' + behaviors[b].name + '" behavior (' + targetEventTypes[e] + ') from item ' + i);
                        behaviors[b].remove();
                        continue behaviorLoop;
                    }

                }
            }
        }

    } // end removeBehaviors


} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Remove Button Behaviors');

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines