Skip to main content
JesB-SsPV8V
Inspiring
December 6, 2013
Question

State-sensitive toolbuttons?

  • December 6, 2013
  • 1 reply
  • 617 views

How to activate the button - frame on a roll over (mouse over) command?

Have seen that Peter Kahrel mention this a bit on page 13 inn his ScriptUI pdf, but did not really understand what he meant.

What I really want to do is that; when the mouse pointer is over the toolbutton, the frame around the button will be visible.

JesB

(Peter Kahrel ScriptUI.pdf: http://www.kahrel.plus.com/indesign/scriptui.html)

This topic has been closed for replies.

1 reply

UQg
Legend
December 6, 2013

Hi JesB,

i do it like this and it works

function myEventHandler(ev)

{

    // ev should be an event object, ev.target is the widget that triggered it, ev.type its type.

    if (!(ev.target instanceof Button)) return;

    switch (ev.type)

    {

        case 'mouseover' :

                        // code to apply when the mouse comes over the button

                        break;

        case 'mouseout' :

                        // code to apply when the mouse "leaves" the button

                        break;

        case 'mousedown' :

                        // code to apply when the mouse "pushes" the button

                        break;                       

        case 'mouseup' :

                        // code to apply when the mouse "releases" the button

                        break;       

        case 'mousemove' :

                        // code to apply when the mouse "is moving over" the button

                        break;

        default:

                        // the only one left is 'click'

                        if (ev.detail===2){} // double click

                        else {};

        };

    return;

    };

myBtn.addEventListener('mouseover', myEventHandler);

myBtn.addEventListener('mouseout', myEventHandler);

// etc

I add all possible mouse events individually, but it might be that myBtn.addEventListener('mouse', myEventHandler); works... never tried;)

There is more info about this kind of things in the Javascript Tools guide >  User Interface tools > Event Handling > MouseEvent object.

Xavier.

JesB-SsPV8V
Inspiring
December 6, 2013

Thanks Xavier

I will try it out