XML Feeds

.

[javascript-dev] Sharing is Bug Reporting?

Matthew Aidekman puuukeey at comcast.net
Mon Jun 25 15:56:34 MDT 2007


I wrote this neato jsui. You send it the message "setup 1" and it replaces your titl ebar.    you can even drag your window around!

Unfortunately, it seems that after clicking the close box, and choosing "cancel" from the "are you sure" dialog,  the window doesn't respond to the first click.


is this expected behaviour?

BRAND NEW
intel 2.4GHz 
osx 10.4.9
2GB ram
max 4.6.3
NJ
male
straight
http://www.myspace.com/rainingroses673
favorite new school band: Robin Thicke
favorite old school band: Creed
-------------- next part --------------
// JavaScript Document
autowatch=1;


autowatch=1

var 	height = box.rect[3] - box.rect[1]; 
var	width = box.rect[2] - box.rect[0]; 
var 	aspect = width/height;

var currentval = 0
var label = "my window damnit";
var col0 = new Array(.05,.1,.2)//background
var col1 = new Array(1,1,1) 
var col2 = new Array(.2,.2,.4)
var col3 =new Array(.3,.5,1)

var mywind;



this.box.rect =[this.box.rect[0],this.box.rect[1],this.box.rect[0]+200,this.box.rect[1]+17] 


sketch.default2d()
draw();
 
 function draw()
{	
	with (sketch) {
		glclearcolor(col0);
		glclear();
	
		gradient(0,-aspect,-1,aspect,1,col0[0],col0[1],col0[2],1,col3[0],col3[1],col3[2],1)
	
		
		drawCloseBox();
		
		 drawlabel(label);
		
	}
refresh();
}
 



function set(x)
{

label = x
draw();
}




function drawCloseBox()
{

var tl = sketch.screentoworld(3,3);
var br =  sketch.screentoworld( height-3,height-3);

var t = tl[0];
var l = tl[1];
var b=br[0];
var r=br[1];

sketch.glcolor(col2);
sketch.quad(t,l,0,t,r,0,b,r,0,b,l,0);
sketch.glcolor(col1);
sketch.framequad(t,l,0,t,r,0,b,r,0,b,l,0);
sketch.linesegment(t,l,0,b,r,0);
sketch.linesegment(t,r,0,b,l,0);
}



function drawlabel(x)
{
with(sketch)
	{
	glcolor(col1);
	moveto(0,0,0);
	fontsize(height-6)
	textalign("center","center")
	text(x);
	}

}




function between(i,min,max)
{
if(i>=min&&i<=max)
	{return true}
return false;

}




function onresize(x,y)
{
height = box.rect[3] - box.rect[1]; 
width = box.rect[2] - box.rect[0]; 
aspect = width/height;
draw();
}

var clickx ;
var clicky;
var lastclickwasdrag = false;
function onclick(x,y)
{
post(between(x,2,height-2)&&between(y,2,height-2) ,"\n");

if(between(x,2,height-2)&&between(y,2,height-2)  )
	{
	lastclickwasdrag = false
	this.box.patcher.dispose();
	this.box.patcher.front();
	}
else
	{
	mywind = this.box.patcher.wind;
	post(mywind.location,"\n");

	clickx =x
	clicky =y
	lastclickwasdrag = true
	}

}



function setup(x)
{
if(x==1)
	{
	this.box.patcher.wind.hastitlebar =0
	this.box.rect =[0,0,mywind.location[2]-mywind.location[0],21] 
	
	
	}
else
	{
	this.box.patcher.wind.hastitlebar =1
	}

}




function ondrag(x,y,but,cmd,shift,capslock,option,ctrl)
{

if(lastclickwasdrag)
	{

	deltax = x-clickx;
	deltay = y-clicky;


	post(deltax+mywind.location[0],deltax+mywind.location[1] ,"\n" )  	;

	mywind.location =[deltax+mywind.location[0],deltay+mywind.location[1],deltax+mywind.location[2],deltay+mywind.location[3]   ]
	}

}

var toggle = 0;
function msg_int(x)
{
toggle = x;
}



function color0(x,y,z)
{col0 = [(x/255),(y/255),(z/255)];
draw();}
   
function color1(r,g,b)
{col1 = [r/255,g/255,b/255];
draw();}

function color2(r,g,b)
{col2 = [r/255,g/255,b/255];
draw();}

function color3(r,g,b)
{col3 = [r/255,g/255,b/255];
draw();}




function gradient(dir,l,t,r,b,r1,g1,b1,a1,r2,g2,b2,a2)  //this is a pretty globaly useable block of code, I use it a bunch of times in this library.
{
//direction 0=b2t,1=t2b,2=l2r,3=r2l
var l = (l*aspect*2)-aspect;
var r =(r*aspect*2)-aspect;
var t=(t*2)-1
var b=(b*2)-1
var LB,LT,RT,RB;

switch(dir)  //define the color of each corder
{
case 0:
	LB =[r1,g1,b1,a1];
	RB =[r1,g1,b1,a1];
	LT =[r2,g2,b2,a2];
	RT =[r2,g2,b2,a2];
	break
case 1:
	LT =[r1,g1,b1,a1];
	RT =[r1,g1,b1,a1];
	LB =[r2,g2,b2,a2];
	RB =[r2,g2,b2,a2];
	break
case 2:
	LB =[r1,g1,b1,a1];
	LT =[r1,g1,b1,a1];
	RB =[r2,g2,b2,a2];
	RT =[r2,g2,b2,a2];
	break
case 3:
	RB =[r1,g1,b1,a1];
	RT =[r1,g1,b1,a1];
	LB =[r2,g2,b2,a2];
	LT =[r2,g2,b2,a2];
	break
}

with (sketch) {
		glbegin("quads");
			glcolor(LB);
			glvertex(l,b);
			glcolor(LT);
			glvertex(l,t);
			glcolor(RT);
			glvertex(r,t);
			glcolor(RB);
			glvertex(r,b);
		glend();
	} 
}


More information about the javascript-dev mailing list