How to get the event target?

I recorded the event mask depending on:

App.notifiers.Add ("Hd",.. mpfprojectdir\dev10\src\csharp\projectbase.file path);

Now, how can he obtain the object that triggered the event?  [app.active document.activeLayer] give me only the layer ".  Of course, this does not work in a scenario where the user hides a layer that is not selected.

I'd appreciate any help!

Action handler has no direct access to objects in the object model. It has its own class and object. Sometimes, there may be a more direct access by name. If the event descriptor was the index of the layer or the ID you can use instead of the name.

Sorry, when I threw together for you I only tested hidding layers that do not have the activeLayer. I don't think that the alert is empty is because the top layer was hidden. I think it's because the activeLayer was hidden so the actionReference is different.

Try this (which seems to work for me with both)

try {
    if (arguments.length >= 2) {
    var desc = arguments[0];
    var event = arguments[1];
    // make sure it's the hide event
    if (event == charIDToTypeID('Hd  ')) {
        // get the list of what was hidden
        var list = desc.getList(charIDToTypeID('null'));
        // get the actionReferences from the list
        var ref = list.getReference(0);
        var psClass = ref.getDesiredClass();
        // make sure it was a layer that was hidded
        if(psClass == charIDToTypeID('Lyr ')){
            // check to see what is in the reference
            var dataEnum = ref.getForm();
            // should either be an enum if activeLayer
            if(dataEnum == ReferenceFormType.ENUMERATED) {
                    alert(app.activeDocument.activeLayer.name);
            }else{// or the layer name
                alert(ref.getName());
            }
        }
    }
  }
} catch (e) {
  alert( "Error: " + e + ":" + e.line );
}

Tags: Photoshop

Similar Questions

  • How to get the event when we change our simcard in BB device

    Hi all

    Please, someone tell how to get the event or any listener method that can automatically called when we change our SIM card device.

    Thanks in advance,

    TEJ

    Hi Tej,

    I came across some post, which may be useful for you

    http://supportforums.BlackBerry.com/T5/Java-development/is-there-a-way-to-get-the-mobile-or-phone-nu...

    http://supportforums.BlackBerry.com/T5/Java-development/is-SIM-ID-really-exist/m-p/54407#M5954

  • How to check the event.target type in the "if" statement

    Hi, I have "roll-over" event listener and I wish that only works with music videos (without textfields etc.). I would write something like this:

    if(Event.Target == MovieClip) {do something}

    else {do something}

    This does not work properly.

    How to check the event.target type in the "if"?

    Thanks for any help.

    :

    If (getQualifiedClassName (Event.Target) == 'flash. display::MovieClip') {do something}

    else {do something}

    .

  • How to get the event when you click Add another button in a table.

    Hello
    How to recognize the event in processFormRequest click on the button Add another line of the footer of a table?

    Suppose if the ID is anotherRow (I mean ID of the button to add another line of the footer)

    If I give if (pageContext.getParameter ("anotherRow")! = null)... its not recognizing the event that is returning null only...

    I want to perform certain actions when the user clicks Add another line of footer. Please let me know the details of how identify when add another line is clicked...

    Thank you
    Srikanth

    Hello

    If you have only one table with add_row_button, and then copy the following code works perfectly

    If (tableBean.getName () .equals (pageContext.getParameter (SOURCE_PARAM)))
    (& ADD_ROWS_EVENT.equals (pageContext.getParameter (EVENT_PARAM)))
    {
    ...
    }

    tableBean is the Handle for your advanced table, hope, it will help you.

    Kind regards
    Out Sharma

  • How to get the events of the ItemRenderer

    Hello, I have a little problem. In my application, I use a list and build its elements with an itemRenderer. In this itemRenderer I have on each line, 1 label and 1 button. When I press the button I want to send this event in my main application... How can I create a communication between myApplication and itemRenderer?

    Thx for all

    Max

    
    
        
            
        
        
            
                
                    
    
                        
                            
                        
    
                    
                
            
        
    
    

    You can use the code above. Let me know if you have any questions.

  • How to get the event when the window is iconified?

    I want to set animation after I click the icon.
    Please help me.
    Thank you.

    stage.iconifiedProperty () .addListener (new InvalidationListener() {}
    @Override
    public void invalid (observable observable) {}

    }
    });

  • How to get the page change event?

    Hello.

    I know that get changed event document as ISignalMgr-> GetServiceID of CResponder::Respond.

    But how to get the event page?  average of the event's page add, delete, etc...

    Thank you.

    Hi K159,.

    You can spy on the InDesign debug Test/Spy/SpyPreferences menu for the observer notifications. Can add or remove a page and to analyze the output of the spy.

    On the kDocBoss, there is an interface IPageList form you can get the number of pages.

    Markus

  • How to get the class Loader of Progress event

    I was charge test.swf file threw Loader class. How to get the class Loader of ProgressEvent, IOErrorEvent.

    function getLoader() {}
    var loader: Loader = new Loader();
    loader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, progressHandler)
    loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler);
    var request: URLRequest = new URLRequest ("test.swf");
    Loader.Load (request);
    }
    function progressHandler(event:ProgressEvent):void {}

    get the class loader
    }

    function ioErrorHandler(event:IOErrorEvent):void {}
    get the class loader
    }
    getLoader()

    the event target has a property of charger:

    Event.Target.Loader

  • How to get the targeted object

    can you tell, how to get the object currently targeted in a class

    for example, if I use the labelfield that has his focus, how to get and make changes to the text of labelfield

    I hope that you can get that I tried 2 say

    Thank you

    Not in a class, screen...

    Features screen with a method called getFieldWithFocus...

    Check it out...

    See you soon...

  • How to get the current location in the event thread?

    Hello!

    Can U pls tell me how to get the location where the thread object, it is in method() execution of MenuItem. PLS, tell me-

    I also used the different thread for the getLocation() method. But I do not have the coords of geo location...

    PLS, suggest me-

    My code is as below:

        private MenuItem getGeoCodes=new MenuItem("Current Coords",100,1){
    
                                 public void run(){
                                     double[] coords=getLocationCoords();
                                     this.wait(12000);
                                     System.out.println("Latitude :"+coords[0]+" "+"Longitude:"+coords[1]);
                                 }
    
                     };
    
        private double[] getLocationCoords(){
            Criteria criteria = new Criteria();
            criteria.setHorizontalAccuracy(500);
            criteria.setVerticalAccuracy(500);
            LocationProvider locationProvider = LocationProvider.getInstance(criteria);
            Location location=null;
            new Thread(){
               public void run(){
                       locationProvider.getLocation(60);
               }
            }
            QualifiedCoordinates qualifiedCoordinates=location.getQualifiedCoordinates();
            double[] coords=new double[]{qualifiedCoordinates.getLatitude(),qualifiedCoordinates.getLongitude()}   ;
             return coords;
        }
    

    But I myself NullPointerException. Coordinates get successfully, if we run the location capability in different function, rather than the event thread.

    Please help me-

    In my opinion, which may be too complicate things a bit. I think he's trying to do is register a LocationListener with his object of LocationProvider. Callback methods, send a message to the UI event thread as follows (no need to spawn threads):

    UiApplication.getUiApplication().invokeLater( new Runnable() {
        public void run()
        {
            // This code will execute on the event thread
        }
    });
    

    EDIT: If your interval is short, you can consider implementing this executable as a class and store an instance in the front.

  • Get-VIEvent - how to export the event type?  error, warning, or info

    Hello

    I know that the Get-VIEvent command allows you to specify the type of events to get back... that is to say [-Types < EventCategory [>]

    but, I want to extract all the events and export them to a CSV file. I want one of the columns to be "EventCategory", which will be ERROR, WARNING, or INFO, but I can't seem to find it.  $_. GetType(). Name gets me the type of event, but not the category.  I know that I can have my script executed 3 times (each time specifying the - parameter Types) but I want to run only once.  Any ideas?

    Thank you!

    Jeff

    Hello, horningj-

    I worked on a few elements that should attract the event category.  The first selects a few properties, including a calculated property that gets the event category:

    ## works well if no events of type 'EventEx'## get the .Net View object of the EventManager (used for getting the event Category) $viewEventMgr = Get-View EventManager ## get some VIEvents, select a few properties, including a calculated property for EventCategory Get-VIEvent | Select FullFormattedMessage, CreatedTime, @{n="EventCategory"; e={$strThisEventType = $_.GetType().Name; ($viewEventMgr.Description.EventInfo | ?{$_.Key -eq $strThisEventType}).Category}}
    

    It becomes VIEvents (the last 100, because I did not specify the parameter - MaxSamples) and returns the properties of data.  The calculated "EventCategory" property uses the type of the VIEvent object to search for in the collection of items EventDescriptionEventDetail in ownership eventInfo found in .net object View for the EventManager.  He then grabs the 'Category' of the corresponding element of EventDescriptionEventDetail property.

    Works fine unless you have any VIEvents type "EventEx" - then, this 'research' in EventDescriptionEventDetail collection method fails, because there is more than one element of this type (there are 91 of them at the moment).

    This led me to the next bit.  It is similar to the previous method, but it handles EventEx events too:

    ## get the .Net View object of the EventManager (used for getting the event Category)$viewEventMgr = Get-View EventManager
    
    ## get some VIEvents (the last 100, as "-MaxSamples" is not specified) Get-VIEvent | %{    ## put the pipeline varible into another variable; get its type    $oThisEvent = $_; $strThisEventType = $_.GetType().Name    ## if this event is of type "EventEx"    if ($strThisEventType -eq "EventEx") {        $strEventTypeId = $oThisEvent.EventTypeId;        ## get the EventInfo item (of type EventDescriptionEventDetail) whose "FullFormat" property begins with the EventTypeId of the VIEvent at hand, and get its "Category" property        $strCategory = ($viewEventMgr.Description.EventInfo | ?{$strRegexPattern = "^$strEventTypeId\|.*"; $_.FullFormat -match $strRegexPattern}).Category    } ## end if     ## else, can just grab the EventInfo item whose "Key" is the same as this event's type    else {$strCategory = ($viewEventMgr.Description.EventInfo | ?{$_.Key -eq $strThisEventType}).Category}    ## add a NoteProperty "EventCategory" to this event    $oThisEvent | Add-Member -MemberType NoteProperty -Name EventCategory -Value $strCategory -PassThru} | Select FullFormattedMessage, CreatedTime, EventCategory
    

    It seems that the EventTypeId of the event returned by Get-VIEvent is included in the first part of the property FullFormat of elements EventDescriptionEventDetail with EventEx key, separate from the rest of the value by a vertical pipe.  Thus, the EventTypeId of the VIEvents can be used to make a match on EventEx of events .net EventManager View object types to get the event 'category' (info, warning, error, user).

    You can, of course, change the Select statements to choice/choose the pieces of information you want to export and then export to a file of data as you please.

    How does do for you?

    * The message has been edited by mattboren on April 5, 2011 - added line at the beginning of the second piece of code '$viewEventMgr = Get-view event Manager.  It was already in the first room and assumes that the user has run the two parts in the same session, but added for completeness.

  • How to get the select button event Radio in my co

    Hello

    I want to get the the radio button selection event in my co, how do I get the event?

    Hello

    841475 wrote:
    I want to get the the radio button selection event in my co, how do I get the event?

    -There is no case of option button.
    -you need to explicitily set the event for the option button.

    Action: FirePaatialAction
    Event: RadioEvent

    -Discover the event in co by code below:

    If ("RadioEvent". Equals (PageContext.GetParameter (EVENT_PARAM)))
    {
    -In the case of a radio button. :))
    }

    Concerning
    Meher Irk

  • Area hideShowHeader: how to get the name of region on Hide/Show Event

    Hello

    I would like to retrieve the name of the region (hideShowHeader) when I click on the hide/show icon. I know how to catch the event but some OAWebBeanConstants I always check null... any idea?

    Thank you very much, Pier Paolo.

    Hello

    Try to print below in LIC...

    System.out.println ("name of the event:" + pageContext.getParameter (OAWebBeanConstants.EVENT_PARAM));
    System.out.println ("the Source of the event:" + pageContext.getParameter (OAWebBeanConstants.SOURCE_PARAM));
    System.out.println ("value:" + pageContext.getParameter (OAWebBeanConstants.VALUE_PARAM));

    Thank you
    Mukesh Uchaniya

  • How to get the selected DataGrid item?

    Hello

    I have a datagrid

    < mx:DataGrid = "10" XY = dataProvider "36" = "{acEmaillist}" width = "319" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Full name" dataField = "cn" width = "150" / >
    < mx:DataGridColumn headerText = "Email" dataField = "mail" width = "150" / >
    < / mx:columns >
    < / mx:DataGrid >

    I want to select a name, click it, get the selected name and save it in a string variable. Please let me know how to get the selected name when I click it. Thank you very much.

    M

    This code can help.


    http://www.Adobe.com/2006/mxml"width ="100% ">

    Import mx.controls.DataGrid;
    Import mx.events.ListEvent;

    [Bindable]
    private var nameStr:String;

    public void getName(event:ListEvent):void {}
    var dg:DataGrid = DataGrid (event.target);
    nameStr = dg.selectedItem.cn;
    }
    ]]>



    Bob Smith
    [email protected]


    Ted Alan
    [email protected]


    Fred Tobs
    [email protected]








  • How to get the name of sbRIO programmatically

    How to get the 'name' and 'Comment' by sbRIO I write to sbRIO-9602 Max in the box of Identification (model, serial number, MAC address, name)?

    Use RT Information.vi of target is located under the range of public services under LabVIEW Realtime.

    Christian

Maybe you are looking for