How to define a "OnMouseOver" event ?

Hello all,

Is it possible to define a kind of "OnMouseOver" event in JavaScript ?
I mean, I have a list box, and I'd like to execute some actions when the mouse is over a row, without clicking any button.
I'd like also to return the number of the line above which is the mouse.

Thank you in advance.

Best regards,

Nasser
In JavaScript? No.

But in Igor's language, you can add a window hook function to the window containing the listbox, and handle MouseMoved events. You will get those events whether the mouse button is down or not. You check the eventMod member of the WMWinHookStruct input to the window hook to see if the mouse button is down or not.

Use the ControlInfo command to figure out where the listbox control is within your window.

The output from ControlInfo has enough information in it to compute what row is under the mouse. It is not a trivial programming project.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hello John,

Thank you for the reply. I meant : "Is it possible to implement in Igor language an event-driven function that has the same behaviour as the JavaScript instruction "OnMouseOver"?"

Indeed, I'd like to detect when the mouse is over a listbox, without clicking any button.

Best regards,

Nasser
Nasser wrote:
Thank you for the reply. I meant : "Is it possible to implement in Igor language an event-driven function that has the same behaviour as the JavaScript instruction "OnMouseOver"?"

I thought that's what you really meant, but you never know. I've seen some pretty wild questions in my time at WaveMetrics!
Quote:
Indeed, I'd like to detect when the mouse is over a listbox, without clicking any button.

And that is what my response addresses. There is no simple "mouse over" event that you can use inside your ListBox procedure. You have to do it with a window hook.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thank you John,

Now I remember an Igor example with a kind of Voltmeter, whose the needle moves in function of the mouse speed over it.
I 'll have a look on it.

Best regards
That's different- that's a custom control. For a very simple example of a window hook, execute this command:

DisplayHelpTopic "Panel Done Button Example"

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hello John,

Thank you, here is a snippet for those who want to implement such a stuff :
First, we have to install the window hook. I've written it in the function that creates the Window.

    NewPanel /W=(28,50,1272,955) /N=MyPanel as "This panel contains a ListBox, called lb1 (not implemented here)"
//(blablabla)
    SetWindow OWLSTONE_Panel hook(MyHook)=MyWindowHook_ListBox //27-06-11


In another function :

Function MyWindowHook_ListBox(s)
    STRUCT WMWinHookStruct &s
   
    variable YinListbox
   
    ControlInfo /W=MyPanel Lb1
   
    If((s.MouseLoc.h >= V_left) && (s.MouseLoc.h <= (V_left+V_Width)) && (s.MouseLoc.v >= V_top) && (s.MouseLoc.v <= (V_top+V_Height)))
   
        strswitch( s.eventName )
            case "mousemoved":
                YinListbox = s.MouseLoc.v-V_top
                print floor(YinListBox/V_rowHeight)+V_startRow
                break
        endswitch
    Endif
   
End