Jump to content

Mouse Events


Recommended Posts

Hey all,

Been struggling through figuring out various aspects of the HDK. Already posted on the SideFX forums, but so far no response--you can see it here.

Instead of double-posting, I have a similar question instead. In the signature of handleMouseEvent, you have access to UI_Event. What I want to do is somehow distinguish between the start of dragging and the end. The first can be done easily enough if you have the second. The function does not get called on mouse-down, but only seems to get called during a drag or on the mouse-up.

I figured that the event->type (UI_EventType) would tell me what I needed, but it is always UI_EVENT_VALUE_CHANGE. The only way to tell the difference that I can see so far is that the value (event->value) is no longer a valid float array, but that is a pretty terrible, hacky, way to see the type of event.

Is there some other way to tell? Any help on this would be immensely appreciated!

Thanks!

~Joel

Edited by megalith
Link to comment
Share on other sites

Can't believe I'm responding to my own message so quickly, but after posting it, I figured out the answer to my own question. Kinda hate it when that happens. <_<

Anyways, here is the solution I came up with. It now seems to make a lot of sense. Here is the code I have:

// This event happens when you are dragging the mouse or
// when the mouse button is released
int MSS_Pen::handleMouseEvent(UI_Event *event)
{
	// Get the renderer for this particular viewport
	RE_Render *re = event-&gt;target-&gt;getRenderer();

	// This gives you the window that the mouse event was
	// generated from
	UI_Object *target = event-&gt;target;

	// Bottom-left corner is (0, 0)
	int x = event-&gt;state.values[1];
	int y = event-&gt;state.values[2];

	// event-&gt;type is always going to be UI_EVENT_VALUE_CHANGE in
	// a mouse event handler, so we need to check the reason for
	// the event instead.

	if ( event-&gt;reason == UI_VALUE_START )
	{
		// Start creating the curve
	}
	else if ( event-&gt;reason == UI_VALUE_ACTIVE )
	{
		// Add the points
	}
	else if ( event-&gt;reason == UI_VALUE_CHANGED )
	{
		// Finish creating the curve
	}

	return 0;
}

My question on the other forum still holds, however, so if anyone has any ideas on how to do that one, please do tell! :P I'm guessing it has something to do with the target, but getting such a generic UI_Object makes it an obscure solution. I've looked through the headers for possible solutions, but so far no luck. So if any of you with more experience with the HDK can shed some light on it, that would be awesome!

Thanks!

~Joel

Edited by megalith
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...