I have:
Keyboard "chords", e.g. Ctrl + typing
Copy and pasting (e.g. Ctrl+A, Ctrl+C, Ctrl+V)
Drag and drop
Drag by N pixels
Mouse hovering
Right mouse click
Drawing on a canvas
What else can you do with it?
Why do not you take a look into the methods here? As far as I can see you already have mentioned important ones. You also can do pause, release, move to the middle and offset of element, keyup, keydown and context click etc.
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
I'm developing a small Qt application similar to the DiagramScene example. I have subclassed QGraphicsView instead of QGraphicsScene. My view is zooming in and out with the mouseWheel, I can drag it with the mouse and I can add Nodes and Links with clicking.
I click on one Node, (the first end of the line item is set), then move the mouse (the second end of the line is following the mouse cursor), then I click on the second Node and anchor the second end of the line item to this second node.
The problem is, when the view is zoomed in, or I have moved the view, when I click on a Node and move the mouse, the preview of the link is not visible. When I click on the second Node - the link is still not visible. The link between the two Nodes becomes visible only after I zoom out or drag the view to some point and it intersects with the sides of the view.
Any ideas how to fix this?
Thank you so much in advance.
I finally fixed it. I was wrong to use data members for the coordinates (also the bounding rect and paint method) of my custom Graphics items. I changed the code using the setPos() function which gives the right coordinates to my items. #Merlin069 thank you, actually your last question got me thinking whether I set the coordinates correctly.
I have implemented Finger Scrolling to one of my QListWidget.
I have taken refernce from
http://www.developer.nokia.com/Community/Wiki/Qt_Kinetic_scrolling_-_from_idea_to_implementation
Now the problem is on_current_row_changed event of QListWidget gets fired when i scroll up and down my List.
How i can avoid this on click only it should behave like click not on Scroll.
Starting from Qt5 this is as simple as:
#include <QScroller>
...
QScroller::grabGesture(myListWidget, QScroller::LeftMouseButtonGesture);
For touch screens use TouchGesture instead of LeftMouseButtonGesture.
If the widget doesn't inherit QAbstractScrollArea (e.g. QWebView):
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setWidget(myWidget);
QScroller::grabGesture(scrollArea, QScroller::LeftMouseButtonGesture);
Be sure to resize the widget to its content size.
You need to test whether the finger has moved between mousePress and mouseRelease. You can extract the position of the press, so if you store it in an intermediate variable, then test it against the position of the mouseRelease (say using QPoint::manhattanLength()), you can tell whether the finger has moved. If it has, the user is scrolling, if not, they're clicking.
EDIT: Looking at the code you've linked to, they're already doing the above. Could we see some more of your reimplemenation?
I have a component called X. I'm trying to make a menu come down from it when I put my mouse over it.
I have a mouseOver handler which changes the component's state to another state which shows an extra child component (the menu) on the lower part. This of course makes the X component grow.
I also have mouseOut event handler which makes the menu disappear by returning component X to its original state.
When I move the mouse over the component the menu appears as expected. But when I move the mouse down to the menu that is now visible, as soon as I touch it, it disappears. This way it's impossible to reach the menu.
I guess the mouseOut event is triggered as soon as I move out of the old boundaries. Is this so? And how can I avoid it? The new boundaries should now consider the extra child with the menu.
Thanks in advance,
Nuno
When you move over the child element you are mousing out of compo0nent "X".
Without seeing code I can't really help you. However you might want to try a few things.
Make a function that tests hit area
of the mouse and component and only
dispatch the event if it passes a
mouse out only if it isn't over your
component. Your component shouldn't dispatch a mouse out event just because the mouse moved out of the component
Change your listeners as needed
Event propagation
But really there is no way I can help more without code.
I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cursor passes over this element the cursor automatically changes without me having to respond to mouse events.
Is it possible? Does Flash support this in DisplayObject or something?
It seems the Flash SWF is overriding me. Some objects automatically display the hand cursor with mouse-over, and I can't see a way to turn this off on a DisplayObject?
To set the the "Hand" cursor, as soon as the mouse hovers over a element you have to specify these properties:
<mx:VBox
useHandCursor="true"
mouseChildren="false"
buttonMode="true">
However this only works for the Hand cursor. Also take care of the required mouseChildren attribute. You either have to set this to false to achieve the cursor for all contained items or you have to specify the attributes useHandCursor and buttonMode for all elements. However the side effect of settings mouseChildren to false is that all mouse events (mouseOver, mouseOut, click,...) on child elements will no longer work.
In case you want to use a different cursor than the hand cursor I am afraid you have only two possibilities:
Replace the standard hand cursor by your cursor
Use the mouseOver and mouseOut events to set the cursor programmatically.
In any object inheriting from Sprite whose buttonMode and useHandCursor properties are both true, you'll get a hand cursor by default when you roll over it. Some objects do this by default, correct; Button and LinkButton are examples you've probably noticed. Simply setting useHandCursor to false on any of these components will disable the hand cursor easily enough, even when its buttonMode property (which is responsible for dispatching click events) is set to true.
If you want to set your cursor to anything else on mouseOver, though, you'll have to respond to mouse events; there's no way around that. Depending on your design goal, you could break that work out somehow, maybe by inheriting from some other object and then overriding its default behavior, but in some form or other, the runtime needs to know you want those mouse events handled.