Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Blacko0ps

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

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
2 people like this

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