ToolBar Button Image Change when Clicked

Ok, now I’m gettin fancy. How do I make a toolbar button’s image change when the button is clicked (mousedown)? and then change back when released (mouseup)?


In case of using two-state buttons it is possible to define both images.


For example if you intialize toolbar from the xml. The “mousedown” image is set by imgdis attribute:










That doesn’t work because this is not a two-state button.  That does change the image when I disable the button via myToolbar.disableItem(“btn0”).  However, the image does not change when mousedown on that image.  I’ve tried dhtmlxEvent(buttonElem, “mousedown”, fnThatSetsButtonImg); but that doesn’t seem to work either.  Basically, if I could figure out a way to throw a onMouseDown event onto the button, I could take care of it.  Does the button element in the toolbar support onMouseDown in any way?




There is setItemImage(itemId, url) method which allows to change item image.


Just for example:


toolbar.attachEvent(“onClick”,function(id){


toolbar.setItemImage(id,new_path);


})







You haven’t answered my question.  toolbar.attachEvent(“onClick”… is not what I’m looking for.  The onClick event fires after mouse button is released.  I want an event when mousebutton is pressed (fire event before release).



Unfortunately, a simple button doesn’t provide any other event handler.


Two-state buttons have both onBeforeStateChange and onStateChange events.