I am using the click-drag component (https://github.com/jesstelford/aframe-click-drag-component) to drag entity's across the screen, and this is done by the mouse (not the cursor that is fixed in the middle of the screen). My question is how can I emit an event by clicking on the entity with the mouse and not with the cursor. (I am trying to clone the enity i click on and moving that one.)
A-Frame's cursor component has a mouse mode.
<a-entity cursor="rayOrigin: mouse">
Related
I'm working on Drag and Drop.
I'm dragging some buttons from a VBox to another VBox.
What I'm seeing now is that the OnDragEntered event is fire only when the mouse cursor enters in the border of the target.
My question is: how can I have a Drag Event ( or another event ) fired when the source button border overlaps the target list border?
thank you very much
drag-and-drop doesn't support that by itself. You can't just drag shapes and receive onDragEvent when they collide with others.
You need to implement bounds collision during drag by yourself, there is a good example here: Checking Collision of Shapes with JavaFX
For exame, the enable vr mide button in the lower right hand corner. I need the buttons and text to appear and stay fixed to the screen when an event is triggered. Similar to how a canvas and button works in unity.
Parent the buttons to the camera. Then they will stay locked to the camera.
Move the buttons using the position component, and they will move in their local coordinate space.
Parent/child relationships are created by nesting the entities, like this.
<a-scene>
<a-box>
<a-sphere></a-sphere>
<a-light></a-light>
</a-box>
</a-scene>
I have a QwtPlot and currently have it set up so I can pan on the graph by pressing and holding down the left mouse button. This is done in my eventFilter and handling the QEvent::MouseMove case.
I then wanted to be able to display the values of the curve when the mouse hovers over the curve. This is also done in the MouseMove event. I am able to do this by setting setMouseTracking(true), however, as a side effect, the window now pans by tracking my mouse movement.
I can only seem to be able to do one or the other, but not both at the same time.
How can I allow for panning on my plot by pressing and holding the mouse button, while also displaying values based on where the mouse is position without causing the panning to be effected?
Whithout having mouseTracking enabled a mouse press is implied when receiving mouse move. When enabling it you also have to handle mouse press/release to know about if you are moving in pressed state.
I have a QGraphicsScene. I have a video running on the scene. On top of video I add a zooming window which is a QGraphicsItem. I drag and drop this window using drag events of QGraphicsScene. This works fine.
I have to show the scene co ordinates everytime the mouse moves. For this I use a QGraphicsTextItem in MouseMoveEvent of graphics scene. The problem is when I write the MouseMoveEvent the drag and drop events stop responding.
Why does this happen?
Thank You
You likely forgot to call the base class's method:
void MyScene::mouseMoveEvent(QGraphicsSceneMouseEvent * ev) {
QGraphicsScene::mouseMoveEvent(ev);
// do your own processing
}
Another possible factor is your coordinate item being in the way of the drop - you could simply move it down a pixel or two so that it's below the mouse pointer's hot spot.
I'm stuck on how to approach this. I have a QGraphicsItem within a scene, and I'm passing a hover event from the scene to this child. While the move event occurs (I'm just using mouseMoveEvent with mouse tracking on), I want another QGraphicsItem to follow the cursor.
I don't need any collision detection, drag and drop, etc. Just an item that follows the cursor. The only two ways I can think of are...
While the mouse moves, draw a new QGraphicsItem at the mouse position. I would need to clear the scene, redraw everything, and draw the new position on top.
Somehow use the animation framework and whenever the mouse moves, animate the QGraphicsItem to move to the new mouse position in 1 millisecond.
I'm probably either overthinking this or unaware of another way to do this... any suggestions?
I did it like this
Create the GraphicsItem cursor which will be moved with mouse-cursor, and store its pointer somewhere (in scene subclass for instance. I have a toolset, so for me it's in one of these tools)
Set its Z-Value (QGraphicsItem::setZValue) so that the cursor will be painted above all other items in your scene
Track QGraphicsScene::mouseMoveEvent events, forward these events down to the cursor pointer, and update item's position
that's it.
I guess it corresponds to your solution 1, except you don't have to clear the scene thanks to z-value feature.