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

Detecting attributes change for view preference (Measurement units)

Explorer ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

Hi,
Can someone help us? We are developing a panel using Javascript and CEP. How can we detect if a user changes horizontalMeasurementUnits or verticalMeasurement units? We have already tried adding an eventlistener to viewPreference object but the event is not triggered and the callback is never called.

Thanks
Jean-Lou

TOPICS
Scripting

Views

144

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

People's Champ , Feb 20, 2021 Feb 20, 2021

Hi Jean-Lou,

 

Actually, there is one way to tackle this given that when the user switches to another unit, (s)he basically calls a menu action. And menu actions can have event listeners attached to the invokation event.

 

//Listening to calls to "Millimeters" menu
#targetengine "invoking_mm_unit"

//Storing if event listener has been already set (in case script is called multiple times)
var isSet = isSet || false;

//Adding listener to "Millimeters" menu action call
(function main(){ 

    //VARS
 
...

Votes

Translate

Translate
People's Champ ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

LATEST

Hi Jean-Lou,

 

Actually, there is one way to tackle this given that when the user switches to another unit, (s)he basically calls a menu action. And menu actions can have event listeners attached to the invokation event.

 

//Listening to calls to "Millimeters" menu
#targetengine "invoking_mm_unit"

//Storing if event listener has been already set (in case script is called multiple times)
var isSet = isSet || false;

//Adding listener to "Millimeters" menu action call
(function main(){ 

    //VARS
    var 
        //The reference to the "Milimeters" menu action
        ma = app.menuActions.itemByName("$ID/Millimeters"),
        
        //The event handler function
        evHandler = function(ev){
            alert("Doc unit has just been set to Millimeters");
        };

        //If the event listener hasn't been set yet, let's add it.
        if ( !isSet ) {

            //Let's store the info
            isSet = true;

            //Let's add the event listener to the menu invokation
            ma.addEventListener ("afterInvoke", evHandler);
        }
})();

 

So there, we want to catch the moment when user clicks on the "Millimeter" item either in horizontal or vertical ruler, and in the cross section.

 

Hope that helps,

 

Loic

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