#1
|
|||
|
|||
Mouse problem
Hi,
trying to develop a different navigation for vizard, I’m having three problems with the mouse commands: 1. When I bring the mouse up, at a certain position close to the top the program throws it down (MOUSEMOVE_EVENT), the same happens at the bottom, the mouse gets pushed up at a certain positon. 2. Also, when I click the ‘tabb’ and the left mouse-button (in the program below) and release the mouse and tabb again, the view still changes and moves in, also I did not program that. 3. How could I implement a keyboard-command that get’s only triggered if the user presses shift+ctrl (this question is not very important, so if it is complicated I just take another key). Steve Code:
view = viz.get(viz.MAIN_VIEWPOINT) view.translate(2.50, 1.01, -0.25)#1.3269580602645874, 1.013837456703186, -0.55598777532577515) view.rotate(-90,0,0) mouseIsMovingUp=1 pointIsMovingRight=1 pointIsMovingUp=1 oldMousePos=0 currentMousePosX =0 def mykeyboard(whichKey): print 'This key was pressed: ', whichKey if whichKey == viz.KEY_CONTROL_L: viz.mouse(viz.ON) if whichKey == '65289': print'tabb',pointIsMovingUp if viz.buttonstate()==1: if pointIsMovingUp==1: viz.mouse(viz.OFF) print 'pointIsMovingUP==1' #print 'viz.get(viz.MAIN_VIEWPOINT):', view.get(viz.HEAD_POS) view.translate(view.get(viz.HEAD_POS)[0],view.get(viz.HEAD_POS)[1]+.05,view.get(viz.HEAD_POS)[2]) return if pointIsMovingUp==0: viz.mouse(viz.OFF) print 'pointIsMovingUP==1' #print 'viz.get(viz.MAIN_VIEWPOINT):', view.get(viz.HEAD_POS) view.translate(view.get(viz.HEAD_POS)[0],view.get(viz.HEAD_POS)[1]-.05,view.get(viz.HEAD_POS)[2]) return viz.callback(viz.KEYBOARD_EVENT, mykeyboard) def mymousemove(horz, vert): global mouseIsMovingUp,pointIsMovingRight,pointIsMovingUp, oldMousePos,currentMousePosX if vert>0: mouseIsMovingUp=1 pointIsMovingUp=1 print 'up' return if vert<0: mouseIsMovingUp=0 pointIsMovingUp=0 print 'down',pointIsMovingUp return #print 'horz, pos',horz, pos if horz>currentMousePosX: pointIsMovingRight=1 #print 'in right1' if horz<currentMousePosX: pointIsMovingRight=0 #print 'in right0' oldMousePos=currentMousePosX currentMousePosX = viz.mousepos()[0] print 'oldMousePos',oldMousePos,currentMousePosX #print 'My mouse moved to: ', horz, vert viz.callback(viz.MOUSEMOVE_EVENT, mymousemove) #def mymouse(whichButton): # if whichButton == viz.MOUSEBUTTON_LEFT: # #viz.mouse(viz.ON) #viz.callback(viz.MOUSEUP_EVENT, mymouse) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|