eventDragStart being called only single time ?

[blockquote]Hello,

I’ve got an application where I need to drag the background grid within the x axis using mouse/touch interactions.
I’m using this code to do that:

[scode lang=“C++”]void MyApp::eventDragStart(int buttonIdx, pvr::PointerLocation loc)
{
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

shaderManager.use(shaderProgramGrid);
// here I’m updating the appropriate matrices
// in order to multiply them with projection and send to a vertex shader

projectionModel = projection * this->getMyTransformMatrix();

glUniformMatrix4fv(mvpLoc, 1, GL_FALSE, glm::value_ptr(projectionModel));
glDraw…
}[/scode]

it works with errors but the thing is that the rendering is kinda single discrete - it only moves the grid by a single eventDragStart function call - but it needs to be called every time mouse moved or touch moved.
From the inline docs about eventDragStart.[/blockquote]

[blockquote]\description This event will be fired after a movement of more than a few pixels is detected with a button down.[/blockquote]

It says like it will behave like a mouse move or touch move but the result is different.
What am I mis uderstooding here ?
Why the callback function isn’t being called every time mouse or touch moved ?
How to drag things smoothly ?

Hi Fname,

As you point out the function eventDragStart is fired when a user holds a mouse button down and moves the mouse cursor. However this function is only called when the event is detected and will not continue to be called ‘during’ the drag event.

I would like to propose an alternate solution to dragging smoothly, you can use the function getPointingDeviceState().isDragging() to check if the mouse is being dragged (this can be polled in your update loop for example), you could then use getPointerAbsolutePosition() or getPointerNormalisedPosition to retrieve the cursors current position either in pixels or normalised device co-ordinates and then use this information to update your objects position / view matrix etc.

Take a look at the example code below:

[scode lang="{language}"]
Result MyApp::renderFrame() //This function is called every frame
{
if (getPointingDeviceState().isDragging()) //Poll pointer state
{
loc = getPointerAbsolutePosition(); //Get cursor position in pixels
//Update objects position
devObj->uiRenderer.getDefaultTitle()->setAnchor(pvr::ui::anchor::Center, -1.f, 1.f);
devObj->uiRenderer.getDefaultTitle()->setPixelOffset(loc.x, -loc.y);
devObj->uiRenderer.getDefaultTitle()->commitUpdates();
}
//Draw

}[/scode]

Currently there is a bug in the framework where moving the window will invalidate the position returned by the function getPointerAbsolutePosition() and we are currently working to resolve this.

Hope this helps.
Shaun

Hi Shaun,

yeah, that worked out.

thanks !