Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions text box triggers cursor change- trigger based on a layer’s boundaries

  • text box triggers cursor change- trigger based on a layer’s boundaries

    Posted by Riccardo Sinti on October 16, 2014 at 8:53 pm

    I’m not getting any good search result for this so here is my question:

    I’m setting up fake web pages and have text entry fields and links.
    How can I create an expression that will trigger the arrow cursor to change to the hand or type tool when it passes over a certain layer.
    I was thinking along the lines of and if else expression that is triggered when my cursor’s null controller passes over a layer’s boundaries.
    I’m using shape layers right now but I can switch to raster layers if it is not possible with shapes.
    any help or links or search terms to e=help me find my answer?

    Thanks!

    Riccardo Sinti replied 11 years, 6 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    October 17, 2014 at 12:13 am

    Is the layer being hovered over rectangular, so that the expression just needs to determine if a particular point on the cursor is over that rectangle, or is it more complicated than that?

    Dan

  • Riccardo Sinti

    October 17, 2014 at 4:27 pm

    Yes just rectangular and rounded rectangle shapes.
    The layer itself doesn’t really matter because I could create any type of layer (solid, PSD, ext…)
    to act as the triggering layer.
    Thanks!

  • Dan Ebberts

    October 17, 2014 at 5:20 pm

    This should work for the simplest case. This example assumes the layer being hovered over is named “target” and the expression will evaluate to true when the upper left corner of the cursor layer (the layer with the expression) is over the rectangular outline of the target layer.

    L = thisComp.layer(“target”);
    ul = L.toComp([0,0]);
    lr = L.toComp([L.width,L.height]);
    p = toComp([0,0,0]);
    over = ! ((p[0] lr[1]))

    Dan

  • Riccardo Sinti

    October 17, 2014 at 5:32 pm

    Thank you very much, Dan.
    I’m not able to try it out right now but does this work for shape layers?

  • Dan Ebberts

    October 17, 2014 at 5:39 pm

    If you’re talking about the target layer, I doubt it.

  • Riccardo Sinti

    October 20, 2014 at 5:48 pm

    so if i apply this expression to a checkbox control effect I get the warning- expected: ) error occurred at line 5.

    I what I am hoping is that this expression will generate on or off for the checkbox control and then I will use the result to drive an if else expression on my cursor layers.

    Did I apply the expression correctly?

  • Dan Ebberts

    October 20, 2014 at 6:05 pm

    Yikes. That last line really got munched when I pasted it in (must be an HTML thing). Let me try it again with the code window:


    L = thisComp.layer("target");
    ul = L.toComp([0,0]);
    lr = L.toComp([L.width,L.height]);
    p = toComp([0,0,0]);
    over = ! ((p[0] < ul[0]) || (p[0] > lr[0]) || (p[1] < ul[1]) || (p[1] > lr[1]))

    Dan

  • Riccardo Sinti

    October 20, 2014 at 8:26 pm

    Thanks Dan, works great!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy