home *** CD-ROM | disk | FTP | other *** search
- // Lemon (HK) Ltd
- // last modified on 30 July 1999
-
- /*
- new event handler
- onButtonMouseOver
- onButtonMouseOut
- onClick
- onPress
- onRelease
- */
-
- __registered_Button = new Array();
- __preload_images = new Array();
- __onmouseup=null;
- __onmousemove=null;
- __button=null;
-
- function Button(src,alt,speed) {
- this.lyr = SimpleLayer;
- this.lyr(src);
- __registered_Button[__registered_Button.length] = this;
-
- this.glyph = getObject(src+".glyph");
- this.img_off = this.glyph ? this.glyph.src : null;
- this.img_on = alt;
- if (this.img_on) {
- var img = new Image();
- __preload_images[__preload_images.length] = img;
- img.src = this.img_on;
- this.onMouseOver(ButtonMouseOver);
- this.onMouseOut(ButtonMouseOut);
- }
-
- this.activate = ButtonActivate;
- this.deactivate = ButtonDeactivate;
- this.onMouseDown(ButtonMouseDown);
- this.onButtonMouseOver=null;
- this.onButtonMouseOut=null;
- this.speed = speed ? speed : 100;
- this.onClick=null;
- this.onPress=null;
- this.onRelease=null;
- this.enable=true;
- }
- function ButtonActivate() {
- this.enable=true;
- }
- function ButtonDeactivate() {
- this.enable=false;
- }
- function ButtonMouseDown(e) {
- if (__button) return true;
- __button = findObject(this, __registered_Button);
-
- if (NS) document.captureEvents(Event.MOUSEUP);
- __onmouseup=document.onmouseup;
- document.onmouseup=ButtonMouseUp;
- if (IE) {
- __onmousemove=document.onmousemove;
- document.onmousemove = ButtonMouseMove;
- }
- if (__button.onClick!=null) __button.onClick();
- if (__button.onPress!=null) doPress();
- return false;
- }
- function ButtonMouseUp(e) {
- if (!__button) return true;
- if (this.onRelease!=null) this.onRelease();
-
- if (NS && !__onmouseup) document.releaseEvents(Event.MOUSEUP);
- document.onmouseup=__onmouseup;
- if (IE) document.onmousemove=__onmousemove;
-
- if (__button.timeout) clearTimeout(__button.timeout);
- __button.timeout=null;
- __button=null;
- return false;
- }
- function ButtonMouseMove() { return false; }
- function doPress() {
- __button.onPress();
- __button.timeout=setTimeout("doPress()",__button.speed);
- }
- function ButtonMouseOver() {
- var b = findObject(this, __registered_Button);
- if (b != null && b.enable == false) return;
- if (b != null && b.glyph != null) b.glyph.src = b.img_on;
- if (b.onButtonMouseOver!=null) b.onButtonMouseOver();
- }
- function ButtonMouseOut() {
- var b = findObject(this, __registered_Button);
- if (b != null && b.enable == false) return;
- if (b != null && b.glyph != null) b.glyph.src = b.img_off;
- if (b.onButtonMouseOut!=null) b.onButtonMouseOut();
- }
-