public void mousePressed() { 
		Object boundedObj = getTimeLineDrawObject(true);
		TimeLineDraw timeLineDraw = (boundedObj instanceof TimeLineDraw)?((TimeLineDraw)boundedObj):null;
		if (mouseButton == LEFT) { 
			// println("left");
			if (cueTimeLineObject!=null) {cueTimeLineObject=null;}
			if (buttonsDraw.inside(mouseX,mouseY)) {
				Object o = buttonsDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o instanceof TimeLineObject) {
					timeLineButClickHndlr((TimeLineObject)o);
				} else if (o instanceof TimeLineSet) {
					timeLineSetButClickHandler((TimeLineSet) o);
				} 
			} else if (inputBarDraw.inside(mouseX,mouseY)) {
				Object o=inputBarDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o!=null && o.equals("compilerButton")) {
					dynCompiler.setVisible(!dynCompiler.getVisible());
				}	else if (o!=null && o.equals("debugButton")) {
					debugWindow.setVisible(!debugWindow.getVisible());
				}	else if (o!=null && o.equals("midiButton")) {
					midiWin.setVisible(!midiWin.getVisible());
				}	else if (o!=null && o.equals("notesButton")) {
					noteWindow.setVisible(!noteWindow.getVisible());
				}  else if (o!=null && o.equals("logButton")) {
					logWindow.setVisible(!logWindow.getVisible());
				}  else if (o!=null && o.equals("propButton")) {
					propHelper.setVisible(true);
				}  else if (o!=null && o.equals("ifaceButton")) {
					if (ctrl) {
						loadInterface(this.interfaceFile);
						interfaceBuilder.setVisible(true);
					} else {
						interfaceBuilder.setVisible(!interfaceBuilder.isVisible());
					}
				}  else if (o!=null && o.equals("keyButton")) {
					if ("".equals(inputMode) || "123456789X".indexOf(inputMode)==-1) {
						inputMode="X";
					} else {
						cancelInput();
					}
				}  else if (o!=null && o.equals("objectButton")) {
					if (!"O".equals(inputMode)) {
						inputMode="O";
					} else {
						cancelInput();
					}
				}  else if (o!=null && o.equals("filterButton")) {
					if (!"y".equals(inputMode)) {
						inputMode="y";
					} else {
						cancelInput();
					}
				}  else if (o!=null && o.equals("colorButton")) {
					if (!"K".equals(inputMode)) {
						inputMode="K";
					} else {
						cancelInput();
					}
				} else if (o!=null && o.equals("playButton")) {
					playTimeLines(timeLineSelection,"p");
				} else if (o!=null && o.equals("pauseButton")) {
					playTimeLines(timeLineSelection,"");
				} else if (o!=null && o.equals("inputButton")) {	
					if ("FfiJ".indexOf(inputMode)>-1) {
						FileChooserThread fct = new FileChooserThread();
						try {
							if (!"".equals(inputStr)) { fc.setSelectedFile(new File(inputStr)) ;}
						} catch (RuntimeException e) {
							showMessage(e.getMessage(), LogWindow.TYPE_ERROR);
						}
						fct.start();
					} else if ("Tv".indexOf(inputMode)>-1) {
						if (ctrl) {
							FileChooserThread fct = new FileChooserThread();
							fct.start();
							ctrl=false;
						} else {
							String exprString=inputStr;
							if (exprString.indexOf(" ")>-1) {
								int start=inputStr.lastIndexOf(" ", cursorPos-1);
								int end=inputStr.indexOf(" ", cursorPos);
								if (end==-1) {end=inputStr.length();}
								exprString=inputStr.substring(start+1,end);
							}
							if ("".equals(exprString) || exprString.trim().startsWith("$")) {
								exprGetHelper.setInput(exprString.trim());
							} else {exprGetHelper.setInput("");}
							exprGetHelper.setVisible(true);
						}
					} else if ("yI".indexOf(inputMode)>-1) {
						exprGetHelper.setInput(inputStr);
						exprGetHelper.setVisible(true);
					} else if ("k".indexOf(inputMode)>-1) {
						ColorChooserThread cct=new ColorChooserThread();
						cc.setColor(timeLineObject.getAwtColor());
						cct.start();
					} else if ("=".indexOf(inputMode)>-1) {
						if ("".equals(currentMIDIInputDevice) && midiDeviceNames.length>0) {currentMIDIInputDevice = midiDeviceNames[0];}
						controlHelper.setInput(inputStr);
						controlHelper.setVisible(true);
					} else if ("+".indexOf(inputMode)>-1) {
						noteHelper.setInput(inputStr);
						noteHelper.setVisible(true);
					} else if ("/".indexOf(inputMode)>-1) {
						if ("".equals(inputStr) || inputStr.startsWith("$")) {
							exprSetHelper.setInput(inputStr);
							exprSetHelper.setVisible(true);
						} else {
							showMessage("There is only input help for expressions",LogWindow.TYPE_ERROR);
						}
					}
				} else if (o!=null && o.equals("inputField")) {
					int desiredTextWid = mouseX -  inputBarDraw.inputTextLeft;
					int ctr=0;
					int diff=desiredTextWid;
					while (ctr<inputStr.length()) {
						ctr++;
						int ctrWidth =	inputBarDraw.thisFontMetrics.stringWidth(inputStr.substring(0, ctr));
						int newDiff =Math.abs( desiredTextWid - ctrWidth) ;
						if (newDiff > diff) {
							ctr--; break;
						}
						diff=newDiff;
					}
					cursorPos=ctr;
				}
			} else if (topBarDraw.inside(mouseX,mouseY)) {
				Object o=topBarDraw.checkForObjectOnScreen( mouseX, mouseY );
				if (o!=null && o instanceof String) {
					if (o.equals("menu")) {
						if (menu==null) {menu= MenuListing.menu;}
						else {menu=null;}
					} else if (o.equals("showCrosshair")) {
						showCrosshair=!showCrosshair;
					} else if (o.equals("showToolTips")) {
						showTooltips=!showTooltips;
					} 
				}
			} else if (popupWindowDraw.isVisible() && popupWindowDraw.inside(mouseX, mouseY)) {
				// select a event.
				// check for popup window
				Object o=popupWindowDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o!=null && o instanceof Integer) {
					int index=((Integer)o).intValue();
					if (!"".equals(inputMode) && "N=+".indexOf(inputMode)>-1){
						inputStr=(String)popupWindowDraw.getTexts().get(index);
						cursorPos=inputStr.length();
					} else if  (!"".equals(inputMode) && "y".indexOf(inputMode)>-1) {
						String filterStr=(String)popupWindowDraw.getTexts().get(index);
						filterStr=filterStr.substring(2,filterStr.length());
						toggleActivateFilter(filterStr);
						inputStr=filterStr;
						cursorPos=inputStr.length();
						popupWindowDraw.setFilterTexts(this);
					} else if  (!"".equals(inputMode) && "K".indexOf(inputMode)>-1) {
						String s = (String)popupWindowDraw.getTexts().get(index);
						if (s!=null) {
							ColorChooserThread cct=new ColorChooserThread();
							if (s.indexOf( "/")==0) {
								cct.startColor = oscMessageColorMap.getColorFor(s);
								cct.start();
							} else if (s.indexOf( "$")==0) {
								cct.startColor = expressionColorMap.getColorFor(s);
								cct.start();
							}
							setInputStr(s);
						}
					} else if  (!"".equals(inputMode) && "O".indexOf(inputMode)>-1) {
						String s = (String)popupWindowDraw.getTexts().get(index);
						if (s!=null) {	setInputStr(s);	}
					} else if  (!"".equals(inputMode) && "123456789X".indexOf(inputMode)>-1) {
						String s = (String)popupWindowDraw.getTexts().get(index);
						if (s!=null) {	
							String[] keyCombo=s.split("-");
							inputMode = keyCombo[0].trim();
							setInputStr(keyCombo[1].trim());
						}
					}   else if (menu!=null) {
						if (menu == MenuListing.menu) {
							Object[] menuItem =(Object[]) MenuListing.menu.get(index);
							menu = (Vector)menuItem[1];
						} else {
							String[] menuItem = (String[]) menu.get(index);
							char key;boolean alt=false;
							if (menuItem[1].indexOf("ctrl+")==0) {key=(char)(menuItem[1].charAt(5) - 96);}
							else if (menuItem[1].indexOf("alt+")==0) {alt=true;key=menuItem[1].charAt(4);}
							else {key=menuItem[1].charAt(0);}
							keyFunctionMap(key,alt);
							menu=null;
							showMessage(menuItem[2],LogWindow.TYPE_MSG);
						}
					}
				}
			} else if (!ctrl && timeLineDraw!= null &&timeLineDraw.inside(mouseX,mouseY)) {
				Object o=timeLineDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o instanceof Event) {
					eventClickHndlr((Event)o);
					if (shift) {addRemoveSelection();}
					if (alt) {selectSameEvents();} 
				}
				else if (o instanceof String) {
					String comp=(String) o;
					if (comp.equals("scroll")) {
						int[] point = timeLineDraw.getBoundObjectInsideCoord(o,mouseX,mouseY);
						scrollBarDragOffset=point[0];
					} else if (comp.equals("ScrollPosToView")) {
						timeLineObject.scrollPosToView=!timeLineObject.scrollPosToView;
					} else if (comp.equals("TypeDisplay")) {
						timeLineObject.typeDisplay=!timeLineObject.typeDisplay;
					}else if (comp.equals("Close")) {
						int index = timeLineDisplays.indexOf(timeLineDraw);
						timeLineSelection.remove(index);
						if (index>timeLineSelection.size()) {index--;}
						if (index>=0) {
							setTimelineFromTimeLineDraw(true, (TimeLineDraw)timeLineDisplays.get(index));
						}
						updateTimeLineDisplays();
					}else if (comp.indexOf("g_")==0) {
						groupClickHandler(comp);
					} else if (comp.indexOf("posBar")==0 ) {dragObject = "posBar"; }
				}else if (o==null){
					if ((System.currentTimeMillis() - lastLeftClickTime) <200) {
						timeLineObject.setPosAndNextEvent(getTimeFromMousePos());
					}else {
						timeLineObject.timeSelStart=getTimeFromMousePos();
					}
				}
			} 
			lastLeftClickTime = System.currentTimeMillis();
		} else if (mouseButton == RIGHT) { 
			if (buttonsDraw.inside( mouseX,  mouseY )) {
				Object o= buttonsDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o instanceof TimeLineObject) {
					timeLineButClickHndlr((TimeLineObject)o);
				} else if (o instanceof TimeLineSet) {
					timeLineSetButClickHandler((TimeLineSet)o);
				}
			} else  if (inputBarDraw.inside(mouseX,mouseY)) {
				Object o=inputBarDraw.checkForObjectOnScreen(mouseX,mouseY);
				if (o!=null && o.equals("playButton")) {
					playTimeLines(timeLineSelection,"l");
				} else  if (o!=null && o.equals("inputButton")) {	
					exprGetHelper.setInput("");
					exprGetHelper.setVisible(true);
				} else  if (o!=null && o.equals("inputField") ) {	
					if (System.currentTimeMillis() - lastRightClickTime<DOUBLE_CLICK_INTERVAL) {
						keyCode = ENTER;
						keyPressed();
					}
				}
			}
			//else if (timeLineDraw.inside( mouseX, mouseY )) {
			else if (timeLineDraw!= null && timeLineDraw.inside( mouseX, mouseY )) {
				//TimeLineDraw timeLineDraw = (TimeLineDraw)boundedObj;
				//return if click in popup window
				if (popupWindowDraw.isVisible() && popupWindowDraw.inside(mouseX,mouseY)) {return;}
				//if (slidersDraw.isVisible() && slidersDraw.inside(mouseX,mouseY)) {return;}
				
				Object o=timeLineDraw.checkForObjectOnScreen(mouseX,mouseY); 
				if (o instanceof Event) {eventClickHndlr((Event)o);}
				else if(o instanceof String)  {
					String key=( (String) o);
					if (key.indexOf("g_")==0 ) { groupClickHandler((String)o); }
					
				}
				if ("".equals(inputMode)) {// create event
					saveUndo();
					Event e = getLastEvent();
					if (e!=null && shift) {e=e.getCopy(timeLineObject);}
					else {e=new Event();}
					e.oscIndex=timeLineObject.oscIndex;
					e.oscP5=oscServers[timeLineObject.oscIndex];
					e.eventTime=(getTimeFromMousePos ()/timeLineObject.quantize)*timeLineObject.quantize;
					timeLineObject.timeLine.add(e);
					timeLineObject.rebuildTimeLine();
					timeLineObject.currentEvent=timeLineObject.timeLine.indexOf(e);
					timeLineObject.lastSelEvent=timeLineObject.currentEvent;
				}
			}
			lastRightClickTime = System.currentTimeMillis();
		} else if(mouseButton == CENTER){
			if (!"".equals(inputMode)) {
				pasteClipToInput();
			}
		}