



var popObj = null;

(function(){
	
	BuildUI(this);
	
	function BuildUI(dlg)
	{
						dlg = new Window("dialog"," popupUI test", [0,0,300,200]);
						
							//パネル全体の背景色と表示色を変更
							gDlg = dlg.graphics;
							//背景色設定
							dlgBrush = gDlg.newBrush(gDlg.BrushType.SOLID_COLOR, [1/255*89, 1/255*89, 1/255*89, 1]);
							//表示色設定
							dlgPen = gDlg.newPen(gDlg.PenType.SOLID_COLOR, [1/255*232, 1/255*232, 1/255*232, 1], 1);
							gDlg.backgroundColor = dlgBrush;
							gDlg.foregroundColor = dlgPen;
						
						
						
						dlg.infoText = dlg.add("statictext", [20,50,150,80],"ここを右クリックしてちょ！");
							//フォント色変更
							gInfo = dlg.infoText.graphics;
							infoPen = gInfo.newPen(gInfo.PenType.SOLID_COLOR, [1/255*230, 1/255*168, 0, 1], 1);
							gInfo.foregroundColor = infoPen;
						
						dlg.infoText.addEventListener('click',dlgFunc);
						//dlg.addEventListener('click',dlgFunc2);
						
						
						dlg.infoText2 = dlg.add("statictext", [20,150,150,180],"select : ");
						
						
		dlg.center();
		dlg.show();
						
						
	}
	
	function ReBuildUI(clXY, dSelf)
	{
		
		
		//alert(clXY);
		
		
		LE = "  ";
		list = [ LE + "aaa", LE + "bbb", LE + "ccc", LE + "ddd" ];
		popObj = new Window("palette", "", [ 0, 0, 150, list.length * 20 + 100 ],{borderless: true});
		popObj.location = clXY;
		
		
		popObj.PnlGrp = popObj.add("panel", [0, 0, popObj.size[0], popObj.size[1] ])
		popObj.listPop = popObj.PnlGrp.add("listbox", [ 0, 0, popObj.PnlGrp.size[0], popObj.PnlGrp.size[1] ], list, {numberOfColumns: 1});
		//ヘッダあり
		//popObj.listPop = popObj.add("listbox", [0,0,100,150], list, {numberOfColumns: 1, showHeaders: true,columnTitles: ['Effect']});
		popObj.listPop.onChange = function()
																{
																	dSelf.infoText2.text = "select : " + String(this.selection);
																	popObj.close()
																};
																
		popObj.show();
		popObj.active = true;
		
		
	}
	
	function dlgFunc(dlgD)
	{
		var clickXY = [ dlgD.screenX + 20, dlgD.screenY ];
		
		if(dlgD.button == 2){
			//alert(popObj);
			if(popObj != null){
				popObj.close();
			}
			ReBuildUI(clickXY, this.parent);
		}
	}

})();

