Jump to content
Blacko0ps

How to run an event only when left mouse bottom being held down?(Python

Recommended Posts

Hi Everyone,

I was wondering if there is anyway in Python to run a function only when the left mouse bottom being held down?

Thanks,

Share this post


Link to post
Share on other sites

It should be possible to do using Qt event system if you familiar with it.

What you need to do is to install eventFilter to Houdini's QApplication instance, and catch QMouseEvent there. 

Quick untested code from the top of my head:

app = QApplication.instance()

class Filter(QObject):
    def eventFilter(self, event, **kwargs):
        if isinstance(QMouseEvent, event):
            if event.button() ==  Qt.RightButton:
				# DO stuff
	return super(Filter, self).eventFilter(event, **kwargs)

app.installEventFilter(Filter())

 

Edited by Stalkerx777
  • Like 2

Share this post


Link to post
Share on other sites

Thanks Alex! Unfortunately, I am not familiar with QT event system. Is it a separate package or it's built in in Houdini ? 

Update- Ok, after doing some research I think this what you have been refering to : http://doc.qt.io/qt-4.8/qobject.html#installEventFilter

Still trying to figure out how to install it for Houdini 

Edited by Blacko0ps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×