How to get event target?

I've registered the following Hide event: 
app.notifiers.add("Hd  ", ...file path);
Now, how can get object that triggered the event?  [app.active document.activeLayer]  only give me the 'selected' layer.  This obviously does not work in a scenario where the user hides a layer that is not selected.
I would appreciate any help!

Action Manager does not have direct access to objects in the Object Model. It has it's own classes and object. Sometimes there can be a more direct access than by name. If the event descriptor had the layer index or ID you could use that instead of the name.
Sorry, when I threw this together for you I only tested hidding layers that were not the activeLayer. I don't think the reason 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( 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 );

Similar Messages

  • How to get event.target/event.currentTarget for HTML-5 canvas for click handler

    Hi,
    I hope everyone is doing great.
    I belong to Actionscript background and just started on Flash CC HTML-5 canvas.
    How to get event.target or event.currentTarget in Flash CC for HTML-5 canvas for click event.
    Like we used to do it in AS 3.0
    btn.addEventListener(MouseEvent.CLICK , go);
    function go(evt:MouseEvent){
       trace(" evt - "+evt.currentTarget); // It will let us know the clicked target
    For  HTML-5
    btn.addEventListener('click' , go.bind(this));
    function go(evt){
       console.log(" evt - "+evt.????t); // what is the correct syntax here?
    Thanks,

    Hey guys found the answer from stackoverflow
    it is - evt.target

  • How to get event when app is minimized.

    How to get event when app is minimized in only windows app, not phone version.

    Hi,
    Suspending Event will be called when a windows store app is minimized. It will not hit the Suspending Event when minimised while debugging, So you need to trigger it manually from the VisualStudio Toolbar.
    Also Read
    Application Lifecycle for windows apps
    Pradeep AJ

  • How to get event when any library object added to indesign doc?

    I want to do some operation when any library object is added to doc. So please tell me how to get event when any library object is added to the doc. better provide some code snippet.

    Daves61,
    I need to clarify what kind of event you're interested in.
    1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR
    2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.
    In the first case you work with Pages panel.
    Have a look to file PageTransitionsPanelObserver.cpp from SDK. 
    PageTransitionsPanelObserver::LazyUpdate()
    In the second case you work with Layout window.

  • How to get event press ESC when plugin's GUI is flashUI

    Hi all
    I implement my plugin use GUI is FlashUI (CSExentersion suite).
    when I pressed ESC. My GUI close imidately.
    I want to check whe n ESC press. But I can't get event pressed key for ESC
    I think that my GUI close from Illustrator. But I don't know how to get event press ESC.
    Thank for your help.

    Put a trace() to print the keyCode into the stage's keydown handler and run your extension in debug mode of flash builder, you can check whether ESC is pressed or not.
    However, I don't know how to prevent extension from closing neither.

  • How to get event.columIndex on dragstart (before the actual drag)

    Hi there,
    I would like to know how to get event.columnIndex (ListEvent) when a drag starts within a datagrid.
    I need the index to get the value from a selected cell in a datagrid.
    It works with the itemClick handler (but then I have to click before dragging) on the datagrid but the DragEvent does not have a columIndex for de underlaying datagrid.
    Please advice and thanks.
    Grtz

    The dragStart event is a subclass of a MouseEvent that can be used in
    mouseEventToItemRenderer

  • AS 3.0 how to set event target?

    Hi,
    I am trying to execute an event on a specific target and I am
    not successful in doing this in AS 3.0 since event.target is read
    only. Here is the scenario:
    - I have a button and the path to this button is:
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    I know this because I did install a listener to and when I
    clicked I recorded the path.
    - I would like to execute a click programmatically on that
    path by just creating an event and setting the target to that
    button
    (DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104)
    however I don’t know how to set the target. Can anybody help
    or point me to the right direction so I can do this.
    Thanks…

    zoran,
    Sorry,I didn't explain what to do very clearly :).
    Básically, the event.taget parameter is set when you use the
    dispatchEvent function, so if you want an event to be dispatched
    from a Object you must call the dispatchEvent from this function.
    The line I gave you wont work by itself since I don't know
    how you reference
    DataEntry0._UpdateDeleteProd1.Form10.FormItem102.HBox103.Button104
    in your application.
    But what you need to do is call the dispatchEvent function in
    the Button104 object with the specific event you want to trigger.

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

    Hi, i have "roll over" event listener and i would like to that works only with MovieClips (without textfields etc.). I would like to write something like that:
    if(event.target == MovieClip){ do something }
    else { do something else}
    This doesn`t work properly.
    How to check type of event.target in "if" statement?
    Thanks for any help.


    if(getQualifiedClassName(event.target) == "flash.display::MovieClip"){ do something }
    else { do something else}
     .

  • Acrobat SDK: How to get events and write event handlers in c#

    I am trying out to get events from a pdf doc and handle it in my c# code with the samples that come with Acrobat-SDK. 
    I am yet to understand how I can do it. I am yet to discover the class that provides me the events. All the classes currently expose methods only. It might be that I am missing something for sure.
    Can somebody help?
    My use case is:
    the user will open a pdf doc and my application (or my app can trigger opening the pdf doc)
    when the user selects some text from the pdf doc, my app should get the event
    My event can handle the selection and get the selected text.
    Put a bookmark on the selection in the pdf doc (with additional attributes)
    the pdf doc retains such bookmarks when the pdf is saved.
    bookmarks in the pdf should be available for edit.
    A different app/code should be able to parse and retrieve these bookmarks along with the additional attributes of the bookmark.
    I hope, I have not asked too much.

    There are no “event handlers” for C# in the Acrobat SDK.  You will have to “poll” for things such as selected text.
    Also, I don’t know what sort of “additional attributes” you are thinking about, but that may or may not be possible from C#.

  • How to get requested (target) URL from login page jsp.

    Hi,
    How can I get requested (target) URL from within login jsp page where unauthenticated user was redirected.
    IN other words I need to get target URL that user requested before he was redirected to login page.
    In Weblogic there is "j_target_url" session attribute for this purpose.
    Does NetWeaver have analogue?
    Thanks in advance.

    hi Alex,
    NWDS provides Authentication through Pre defined properties,
    We can trap unauthorised user.
    To know more about this,
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4ecd6eb1-0301-0010-61bd-a3d6bee102c0
    thank you

  • How to get event from message?

    Hi,All:
    I write a run-time interface by CVI, I use TS_EngineRegisterUIMessageCallback to register my callback function, but when message passed to the callback function, as the type is struct IDispatch but not CAObjHandle, I don't know how to read event from message.
    Can you help me to solve it? Thanks
    Chang Zhang

    Hello Chang-
    If your question is simply how to obtain an object handle from an object of type IDispatch, have you investigated the function "CA_CreateObjHandleFromIDispatch"? I would recommend you look over the testexec.prj that is installed along with the TestStand engine (the CVI Operator Interface) and inspect how we handle our callbacks, this may help you understand how to go about emulating the behavior in your own project. To see this particular function in use it may be most helpful to look in the file 'engine.c' and inside the function UIMessageDeferredCallback here you will see the IDispatch pointer being handled and decoded for use by the TS engine.
    Regards,
    Elaine R.
    Applications Engineering
    National Instruments
    http://www.ni.com/ask

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • How to get event 'out of the class'

    I have been reading myself silly about this, I either don't get it or it is very difficult.
    What I want to do:
    1) setup
    2) show panel
    3) handle input in panel
    4) once valid
    5) "get out"
    6) display other panel.
    I can go all the way to 4.
    But I can't get "out" of the panel.
    All I can guess/understand is that I have to trigger an event that will be handled below/outside this panel.
    Has anybody some idea how to do this? Maybe a link to some example code?
    There is tons to read about event handling but the (only) part I understand is about events within classes just as all the examples are (One panel two buttons, two pictures etc)
    I guess the only option I might envision is dividing by zero and catching the error outside the panel.
    That would be bazooking a mosquito, but it also shows what I try to implement.
    I'd be so happy to understand this part of the 'java system' ...
    (please understand that I don't want 'cardlayout', I want to understand what I need to do)
    Much thanks for any help!

    Thank you for your suggestion.
    My problem is that I am (feel?) stuck within the panel.
    So to put it differently, I cannot build a child panel with a button (in the child) that will have the parent pane change color. This as my 'code focus' is within the child panel and I cannot 'activate' code outside it.
    I am totally confused now as to how java works.
    So I cannot write a parent pane with a child pane where the child tests for a name and if the name is correct the child will be removed and some code will put in another child pane with fi a picture.
    This seems so utterly basic to any programmers needs, but I cannot find one example - or I have gone blind looking for it. In my code if I want to read the input field I have to handle it within the child pane, if I want to change child panels I need to do that in the parents panel code. But I can't change the code focus. So the child needs to generate an event that the parents can act upon, but there are no examples while I actually expect tons of examples. So maybe I don't speak 'Java'.
    This meaning that I cannot write a stack of panes and remove them one by one using fi the escape key.
    I am just left clueless by Java.

  • How to get event source from value property changed handler?

    I am relatively new to JavaFX, so perhaps this is an easy question to answer. I am creating in Java code several (e.g., 5) ChoiceBox instances. I add a handler for when the value of the ChoiceBox changes. My code:
    ChoiceBox<String> rpmSelector = new ChoiceBox<>();
    ObservableList<String> rpmSelectorItems = FXCollections.observableArrayList();
    rpmSelectorItems.add(ALL_RPM);
    for (Double engSpeed : engSpeeds) {
        rpmSelectorItems.add(String.format("%.0f", engSpeed.doubleValue()));
    rpmSelector.setItems(rpmSelectorItems);
    rpmSelector.getSelectionModel().selectFirst();
    rpmSelector.valueProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> obsValue,
                String oldValue, String newValue) {
           // How can I get the ChoiceBox that was the source of this event?
    });My question is: in the "changed" method, how do I determine which of the ChoiceBox instances had its value changed?
    Thanks!
    Chris
    Edited by: 976245 on May 15, 2013 1:05 PM
    Edited by: 976245 on May 15, 2013 1:05 PM

         My question is: in the "changed" method, how do I determine which of the ChoiceBox instances had its value changed?You have only one ChoiceBox control. Probably you want to get the selected item. If it is the case you can get it through selectedItemProperty(),
    selectedIndexProperty(), and valueProperty()
            rpmSelector.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
                public void changed(ObservableValue<? extends String> ov, String old_val, String new_val) {
                    System.out.println("Selected item is: " + new_val);
            rpmSelector.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
                @Override
                public void changed(ObservableValue<? extends Number> observableValue, Number oldv, Number newv) {
                    System.out.println("Selected index is: " + newv.intValue());
            rpmSelector.valueProperty().addListener(new ChangeListener<String>() {
                public void changed(ObservableValue<? extends String> ov, String old_val, String new_val) {
                    System.out.println("Selected   value: " + new_val);
            });

  • How to get events from Jtextpane editable with graphic drawn on it ??

    HI,
    I have a Texpane with some string drawn on it at some interval according to scale.
    How do I get the event of click on it and make that particular character editable.

    Try adding a mouselistener to the pane
    appu

Maybe you are looking for