Project

General

Profile

A simple example for a JSlot reacting to an onMouseOver event?

Added by Peter K over 12 years ago

Hello,

I was looking for a simple example of JSlot use in the documentation, but could not find it... I'd like to have a DIV change its CSS class when the mouse is over it, handled completely client-side. Could someone provide a two-line example to demonstrate how it should be done?

Thank you,

Peter


Replies (2)

RE: A simple example for a JSlot reacting to an onMouseOver event? - Added by Wim Dumon over 12 years ago

From the top of my head:

  WText *txt = new WText("try me", this);
  txt->mouseWentOver().connect("function(object, event) {object.className='someclass'}");

No need for a JSlot!

With JSlot:

  slot.setJavaScript("function(object,event) {object.className='someclass';}");
  txt->mouseWentOver().connect(slot);

(order of setJavaScript and connecting to the slot may matter, I'm not sure)

Wim.

    (1-2/2)