Flex Event Blocked by Another Object - apache-flex

I am using a box element to add a transparent overlay to a column of buttons. I want to add a click event to the buttons. However, when you click a button the click event is only triggered on the overlaying box. Is there anyway to pass the event to the underlying button or perhaps a better way to display an overlay without blocking the click event?

If you want a DisplayObject (which nearly all visual things subclass in Flex) to be treated as "transparent" to the mouse (i.e. it won't intercept click events), set that object's mouseEnabled property to false.
e.g.
transparentBox.mouseEnabled = false;

Related

How to make ButtonGroup visible dynamically from another command button?

I have action pane's MyButtonGroup's visible property set to 'no'.
What I want to do is to show (to set its visible property to 'yes') MyButtonGroup when I click Line view button.
I overrode Line view's method gotFocus:
MyButtonGroup.visible(true);
super();
but I also want MyButtonGroup visible property to be false if Line view button is not focused / clicked
for this I overrode the lostFocus method on Line view
MyButtonGroup.visible(false);
super();
so the lostFocus method "does not work", I mean when Line view button is not focused anymore
MyButtonGroup remains visible.
how can I solve it?
Never use gotFocus or lostFocus.
Use the clicked method of LineViewButton and HeaderViewButton instead.
See my pastebin for an example.
That said, you are on the wrong track, the button group would be better placed on the action pane directly above the lines.

Get mouse position outside Flex Panel

I am creating a Flex Panel, which has an image on it. I have set the "buttonMode" and "useHandCursor" property of the image to true. So, whenever I do a mouse over, the cursor changes into a hand tool. I am able to set the mouse-down, mouse-up, mouse-move events on it. But, I see that the mouse-move events only get triggered when I move the mouse inside my Flex panel. I also want to capture the mouse-move event when user moves the mouse outside the Flex panel.
For eg, when user clicks on the image in Flex panel and then drags the mouse(while mouse down) outside the Flex panel, I want to get the current position of mouse while user is dragging the mouse.
Is there any way to get the mouse position outside the Flex panel??
Thanks!
The solution for this is "Mouse-Move" event only.
I need to do the following:
1. Capture mouse-down event on the image.
2. Register for mouse-move and mouse-up event inside the mouse-down event.
3. Inside the mouse-move event get the position of cursor.
4. Inside the mouse-up event unregister mouse-move event.

Setting button focus in a graphcisview

I have placed a few buttons in a Qgraphicsscene, but I don’t know how to navigate to the button from a keyboard.
How would I set the focus to a button from the keyboard?
I assume that you used QGraphicsScene::addWidget() to add the button to the scene? It gives you a proxy object back, QGraphicsProxyWidget *, which inherits QGraphicsItem::setFocus(). But remember that it needs to have set the ItemIsFocusable flag and needs to be visible and active as well.
Additionally (from the setFocus() documentation):
As a result of calling this function, this item will receive a focus in event with focusReason. If another item already has focus, that item will first receive a focus out event indicating that it has lost input focus.

How does Flex click event work inside of containers?

I have a VBox, I assigned a handler to click, and inside the VBox I have components such as images and texts with no handler assigned for click. Would the click function be called when I click on the text and image? If not how can I make it so without assigning handlers individually, but on the container level?
Thanks
Click events "bubble" in Flex. When you click on an images, it bubbles up to its parent, then that parent's parent and so on until there are no more parents left.
If any of these have click listeners they will trigger when they are reached in the bubbling process.
Also in the event the currentTarget will refer to the object that has the listener, and the target will be what was actually clicked.
So in your case if they click the image, the event will bubble up to the container triggering the event, in your listener function the clicked image will be the event.target and the container will be the event.currentTarget.
Also in the bubbling process, it actually starts from the root parent down, this is called the capture phase, then bubbles back up. Your event will trigger when it bubbles back up unless you specify useCapturePhase = true in the event listener. This is how you can stop an event from going to its children. If you use the capture phase then call event.stopPropagation() inside the event listener then the container will receive the event but the child image will not.
It's taken an hour for an answer to this question... it probably would have been faster to just try it. :)
But yes, click events bubble up to parent containers. Adding the handler to the VBox should be fine.
I was pretty sure that containers, such as VBox do not dispatch click events; unless they are bubbled up from the children.
However, clicking on items in your container should trigger the listener on your container, as the Click event bubbles.

Flex Panel doesn't call focusInHandler() when it gets focus

I want to be notified when a FLex Panel gets or loses focus. I've overridden the focusInHandler() and the focusOutHandler(), but they don't get called when I click on the panel.
The panels style changes indicating that it has the focus, but the handler doesn't get called.
What am I missing?
Containers (and implicitly panels) aren't really focusable. Meaning that simply clicking on an empty container won't give it focus, and in consequence, won't trigger the event handler for "focusIn". In order for a container to "gain" focus, a child of that container, that implements IFocusManagerComponent interface, has to gain focus.
So if you want your panel to trigger the "focusIn" event when clicking on it, you should focus a focusable child of that panel on mouse click.
Have you tried to explicitly listen for that event:
myPanel.addEventListener(FocusEvent.FOCUS_IN, myEventHandler);
and made sure that it was getting called?

Resources