Hi Justin!
Thanks, now I finally got it to work with the constructor. 
Your help is much appreciated.
Arvid

On Tuesday, April 1, 2014 9:06:02 PM UTC+2, Justin Israel wrote:
>
> I didn't have time to really test this, but it would be something like 
> this:
> http://pastebin.com/dWFee2xT
>
> It gets rid of the globals inside of Region and just uses my previous 
> suggestion of storing the coordinates locally on the region instance. And 
> it disables itself my removing the event filter after the mouse release. In 
> the few seconds I had to test it, I was seeing something odd, that the 
> event object coming into the event filter was actually just a plain QEvent 
> and not a QMouseEvent for some reason. So the calls to globalX() was 
> erroring out. 
>
>
>
>
> On Wed, Apr 2, 2014 at 7:02 AM, Arvid Schneider 
> <[email protected]<javascript:>
> > wrote:
>
>> Hey Guys, thanks for the Input. I am still struggling. 
>>
>> here is my complete code:
>>
>>
>> REGION_COORDINATES = ['rStart_x', 'rStart_y', 'rEnd_x', 'rEnd_y']
>>
>> class Region(QtCore.QObject):
>>     """ Class contains methods to provide information for a specific 
>> selected region """
>>
>>     global REGION_COORDINATES
>>
>>     def stop(self, value):
>>         self.stopEvent = value
>>
>>     def setCoordinateData(self, coordinateValue, place):
>>         """ stores the x and y coordinate in our global variable """
>>
>>         REGION_COORDINATES[place] = coordinateValue
>>
>>     def eventFilter(self, obj, event):
>>         """ setup the event filter for mouse button press
>>             and mouse button release
>>         """
>>
>>         if event.type() == QtCore.QEvent.MouseButtonPress:
>>             self.setCoordinateData(event.globalX(), int(0))
>>             self.setCoordinateData(event.globalY(), int(1))
>>
>>             return False
>>         if event.type() == QtCore.QEvent.MouseButtonRelease:
>>             self.setCoordinateData(event.globalX(), int(2))
>>             self.setCoordinateData(event.globalY(), int(3))
>>             self.stop(value = True)
>>
>>             return False
>>
>>         return super(Region, self).eventFilter(obj, event)
>>
>> def installRegion():
>>
>>         global filter
>>         filter = Region()
>>
>>         filter.stop(value = False)
>>         stopEvent = filter.stopEvent
>>         
>>         view = omui.M3dView.active3dView()
>>         viewWidget = wrapinstance(long(view.widget()), QtCore.QObject)
>>         viewWidget.installEventFilter(filter)
>>
>>
>> This my code, all I want to do now is kill the event when stopEvent jumps 
>> to True.
>> But how do I accomplish that?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>>  To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/b265518c-9b5c-4497-ae55-c16124da3511%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/b265518c-9b5c-4497-ae55-c16124da3511%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/01967948-60d9-4a36-b9ea-2f3b201e9fc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to