View Single Post
  #2  
Old 07-02-2007, 09:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

There is currently no built-in feature that returns the selected window, but you can compute it manually. Here is sample script that creates a couple windows and will determine which one is selected when the left mouse button is pressed:
Code:
import viz
viz.go()

#Create some windows
window1 = viz.addWindow()
window1.clearcolor(viz.RED)

window2 = viz.addWindow(pos=(0,1))
window2.clearcolor(viz.BLUE)

#Create list of windows to select
windowSelection = [window1,window2,viz.MainWindow]

def SelectWindow():
	"""Returns the window that is underneath the mouse"""
	for w in windowSelection:
		c = w.displayToWindow(viz.mousepos())
		if 0.0 <= c[0] <= 1.0 and 0.0 <= c[1] <= 1.0:
			return w
	return None

#Perform picking on selected window when left mouse button pressed
def PickWindow():
	window = SelectWindow()
	if window:
		print 'Window',window.id,'selected'
vizact.onmousedown(viz.MOUSEBUTTON_LEFT,PickWindow)
Reply With Quote