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.
Related
I have a set of controls which have bindings to frequently changing data values. The data comes from a limited hardware-bus. Therefore, it would be better to disable the binding while the control is not visible on screen. The item's visible-property doesn't help in this case. So, how to determine if an Item-based QML widget is currently visible on screen (and not hidden by an overlay or currently outside the visible area)?
Source: https://forum.qt.io/topic/54116/how-to-check-if-a-item-is-currently-visible-on-screen
I have almost the same problem. Hoping someone here has a solution.
Here's what I would try to get working:
First, I presume there is a ScrollView or Flickable in play here? If so, then hook to signals like Flickable::movementEnded().
Second, when that signal fires, use Item::mapToItem() to check if each of your Item's visible rectangle (based on x, y, width, height) intersects your window's contentItem rectangle. Set the result as a boolean on each of your items and make sure the data retrieval is disabled when it is false (using && or a tertiary JS expression).
Or if more convenient, remove the binding when false and reapply it with Qt.binding() when true.
I have created my own custom QTreeWidget, and overrided the mouseMoveEvent.
It looks something like the below,
MyTreeWidget::mouseMoveEvent(QMouseEvent* aEvent)
{
QTreeWidget::mouseMoveEvent(aEvent); // This line causes the issue
// My logic
}
I'm getting a hovering effect on the treewidget, when mouseMove happens (This is not expected). I have also set the focus (Qt::WA_MacShowFocusRect) to be false. But still, see the hover effect when I move the mouse in and out. I found out this is because of the line - QTreeWidget::mouseMoveEvent(aEvent), which calls the base class implementation which sets the hover. But, I need that to be called to support reorder of tree items, when mouseTracking is enabled.
I don't find any way to unset the hover events. Any help around this?
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.
So, I have a component based on canvas, and within that component I have two images. I have the component listen for a click and when that event occurs one image goes transparent and the other becomes visible.
This part works perfect.
Now, on clicking that component, I also want to do something to the parent canvas, I already have this working for more basic types (image, canvas, text, etc) but the problem with my component is that the click event has the internal image as the target, so what I want to happen to the outside canvas is happening to the canvas of the component.
How do I make my component as a whole the target of any clicks on it?
3.5 SDK
You can make the outer component the target of the clicks by setting mouseChildren = false on the outer component. Clicking anywhere within the component (including on any of the sub-components) will then set the event target to the outer component. Hope that helps.
I handled this by adding a click handler to the children that would stop immediate propagation, then dispatch a click event from the outer component. Wade's solution is much better.
This question is because normally when you want to click a button or link the user expect a HAND in the cursor but in the case of input type="button" you get a cursor arrow , does any know why is this? is cause is inherit from base class input?? and all inputs have pointer cursor?
I Know a simple css lik {cursor:pointer} //make the work... but wait is not make more sense that instead of "cursor:pointer" would be {cursor:hand} //IE support this one.
Hope some have the answer.
It's because it has no defined cursor style so it defaults to default
The "hand" cursor originally arose because of single-click links. And, in a web browser, the <a> element is the link element.
But, in other contexts (Windows forms, etc.), the default cursor (arrow pointer) can click on the buttons, so the browsers are just keeping UI consistent.
A browser could theoretically change the default cursor to a hand for <input type="button"> elements.
But, cursor:pointer; makes more sense for CSS, because it doesn't necessarily have to be a hand image. You can always change your cursors to another image, but the behavior (pointer in this case) defines what you call the cursor, not the image.