Commit 1846a70e authored by Prabhu Ramachandran's avatar Prabhu Ramachandran
Browse files

Control and Shift modifiers were not set during mouse motion, enter and

leave events.
parent 91eb2335
......@@ -188,8 +188,9 @@ class GtkVTKRenderWindowInteractor(gtkgl.GtkGLArea):
def OnMouseMove(self, wid, event):
"""Mouse has moved."""
m = self.get_pointer()
self._Iren.SetEventInformationFlipY(m[0], m[1], 0, 0, chr(0),
0, None)
ctrl, shift = self._GetCtrlShift(event)
self._Iren.SetEventInformationFlipY(m[0], m[1], ctrl, shift,
chr(0), 0, None)
self._Iren.MouseMoveEvent()
return gtk.TRUE
......@@ -197,16 +198,18 @@ class GtkVTKRenderWindowInteractor(gtkgl.GtkGLArea):
"""Entering the vtkRenderWindow."""
self.grab_focus()
m = self.get_pointer()
self._Iren.SetEventInformationFlipY(m[0], m[1], 0, 0, chr(0),
0, None)
ctrl, shift = self._GetCtrlShift(event)
self._Iren.SetEventInformationFlipY(m[0], m[1], ctrl, shift,
chr(0), 0, None)
self._Iren.EnterEvent()
return gtk.TRUE
def OnLeave(self, wid, event):
"""Leaving the vtkRenderWindow."""
m = self.get_pointer()
self._Iren.SetEventInformationFlipY(m[0], m[1], 0, 0, chr(0),
0, None)
ctrl, shift = self._GetCtrlShift(event)
self._Iren.SetEventInformationFlipY(m[0], m[1], ctrl, shift,
chr(0), 0, None)
self._Iren.LeaveEvent()
return gtk.TRUE
......
......@@ -138,30 +138,38 @@ class QVTKRenderWindowInteractor(qt.QWidget):
self._Iren.ConfigureEvent()
self.repaint()
def _GetCtrlShift(self, ev):
ctrl, shift = 0, 0
if hasattr(ev, 'state'):
if (ev.state() & 8):
shift = 1
if (ev.state() & 16):
ctrl = 1
elif self.__saveState:
if (self.__saveState & 8):
shift = 1
if (self.__saveState & 16):
ctrl = 1
return ctrl, shift
def enterEvent(self,ev):
if not self.hasFocus():
self.__oldFocus = self.focusWidget()
self.setFocus()
ctrl, shift = self._GetCtrlShift(ev)
self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY,
0, 0, chr(0), 0, None)
ctrl, shift, chr(0), 0, None)
self._Iren.EnterEvent()
def leaveEvent(self,ev):
if (self.__saveState & 0x7) == 0 and self.__oldFocus:
self.__oldFocus.setFocus()
self.__oldFocus = None
ctrl, shift = self._GetCtrlShift(ev)
self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY,
0, 0, chr(0), 0, None)
ctrl, shift, chr(0), 0, None)
self._Iren.LeaveEvent()
def _GetCtrlShift(self, ev):
ctrl, shift = 0, 0
if (ev.state() & 8):
shift = 1
if (ev.state() & 16):
ctrl = 1
return ctrl, shift
def mousePressEvent(self,ev):
ctrl, shift = self._GetCtrlShift(ev)
self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
......@@ -194,8 +202,9 @@ class QVTKRenderWindowInteractor(qt.QWidget):
self.__saveState = ev.state()
self.__saveX = ev.x()
self.__saveY = ev.y()
ctrl, shift = self._GetCtrlShift(ev)
self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
0, 0, chr(0), 0, None)
ctrl, shift, chr(0), 0, None)
self._Iren.MouseMoveEvent()
def keyPressEvent(self,ev):
......
......@@ -73,7 +73,15 @@ class vtkTkRenderWindowInteractor(Tkinter.Widget):
def BindEvents(self):
""" Bind all the events. """
self.bind("<Motion>", self.MouseMoveEvent)
self.bind("<Motion>",
lambda e, s=self: s.MouseMoveEvent(e, 0, 0))
self.bind("<Control-Motion>",
lambda e, s=self: s.MouseMoveEvent(e, 1, 0))
self.bind("<Shift-Motion>",
lambda e, s=self: s.MouseMoveEvent(e, 1, 1))
self.bind("<Control-Shift-Motion>",
lambda e, s=self: s.MouseMoveEvent(e, 0, 1))
# Left Button
self.bind("<ButtonPress-1>",
lambda e, s=self: s.LeftButtonPressEvent(e, 0, 0))
......@@ -147,9 +155,25 @@ class vtkTkRenderWindowInteractor(Tkinter.Widget):
self.bind("<Control-Shift-KeyRelease>",
lambda e, s=self: s.KeyReleaseEvent(e, 1, 1))
self.bind("<Enter>",
lambda e, s=self: s.EnterEvent(e, 0, 0))
self.bind("<Control-Enter>",
lambda e, s=self: s.EnterEvent(e, 1, 0))
self.bind("<Shift-Enter>",
lambda e, s=self: s.EnterEvent(e, 0, 1))
self.bind("<Control-Shift-Enter>",
lambda e, s=self: s.EnterEvent(e, 1, 1))
self.bind("<Leave>",
lambda e, s=self: s.LeaveEvent(e, 0, 0))
self.bind("<Control-Leave>",
lambda e, s=self: s.LeaveEvent(e, 1, 0))
self.bind("<Shift-Leave>",
lambda e, s=self: s.LeaveEvent(e, 0, 1))
self.bind("<Control-Shift-Leave>",
lambda e, s=self: s.LeaveEvent(e, 1, 1))
self.bind("<Configure>", self.ConfigureEvent)
self.bind("<Enter>", self.EnterEvent)
self.bind("<Leave>", self.LeaveEvent)
self.bind("<Expose>",lambda e,s=self: s.ExposeEvent())
def CreateTimer(self, obj, evt):
......@@ -159,9 +183,9 @@ class vtkTkRenderWindowInteractor(Tkinter.Widget):
"""The timer is a one shot timer so will expire automatically."""
return 1
def MouseMoveEvent(self, event):
self._Iren.SetEventInformationFlipY(event.x, event.y, 0, 0, chr(0),
0, None)
def MouseMoveEvent(self, event, ctrl, shift):
self._Iren.SetEventInformationFlipY(event.x, event.y, ctrl,
shift, chr(0), 0, None)
self._Iren.MouseMoveEvent()
def LeftButtonPressEvent(self, event, ctrl, shift):
......@@ -215,17 +239,17 @@ class vtkTkRenderWindowInteractor(Tkinter.Widget):
self._Iren.SetSize(event.width, event.height)
self._Iren.ConfigureEvent()
def EnterEvent(self, event):
def EnterEvent(self, event, ctrl, shift):
self._OldFocus=self.focus_get()
self.focus()
self._Iren.SetEventInformationFlipY(event.x, event.y, 0, 0,
self._Iren.SetEventInformationFlipY(event.x, event.y, ctrl, shift,
chr(0), 0, None)
self._Iren.EnterEvent()
def LeaveEvent(self, event):
def LeaveEvent(self, event, ctrl, shift):
if (self._OldFocus != None):
self._OldFocus.focus()
self._Iren.SetEventInformationFlipY(event.x, event.y, 0, 0,
self._Iren.SetEventInformationFlipY(event.x, event.y, ctrl, shift,
chr(0), 0, None)
self._Iren.LeaveEvent()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment