Skip to content

Instantly share code, notes, and snippets.

@lukpazera
Last active June 20, 2019 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukpazera/5629217a0ce322a208fa6c9edf53e29b to your computer and use it in GitHub Desktop.
Save lukpazera/5629217a0ce322a208fa6c9edf53e29b to your computer and use it in GitHub Desktop.
How to set up on idle event in MODO SDK.
#include "lx_visitor.hpp"
/*
* OnIdleVisitor is used to perform On Idle Event.
* Evaluate() method will be called once the on idle event is registered.
*
* If you add more methods to this class and want to access them from outside this is how you need to do it:
* onIdleVisitorInstance.loc.method();
* You get direct access to this class contents via '.loc'.
* Don't ask me why ;).
*/
class OnIdleVisitor
{
public:
LxResult Evaluate ();
};
/*
* Example class using on idle events.
*/
class EventQueue
{
public:
EventQueue() :
_onIdleVisitor()
{}
private:
/*
* Call this method when you want to arm on idle event.
* Note that only one on idle event can be armed at a time.
* This is why we disarm an event that was already there and arm new one.
* In my code I make on idle event an event queue.
* Each new event adds to the queue. This is to make sure that when on idle event happens
* it will process all the events that happened up to the point the event is fired.
*/
void _armOnIdleEvent()
{
CLxUser_PlatformService platformService;
platformService.CancelDoWhenUserIsIdle(_onIdleVisitor, LXfUSERIDLE_MOUSE_BUTTONS_UP | LXfUSERIDLE_CMD_STACK_EMPTY);
platformService.DoWhenUserIsIdle(_onIdleVisitor, LXfUSERIDLE_MOUSE_BUTTONS_UP | LXfUSERIDLE_CMD_STACK_EMPTY);
}
CLxInst_OneVisitor<OnIdleVisitor> _onIdleVisitor;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment