Trouble with Flex 3 PopupManager - apache-flex

I'm trying to use the PopupManager class in a Flex3 AIR app to open different kinds of panels but I'm running into some problems with it. I'm using a method like the following with which all panels are opened ..
private function createPopUp(clazz:Class, modal:Boolean = false):IFlexDisplayObject
{
var p:IFlexDisplayObject = IFlexDisplayObject(PopUpManager.createPopUp(_windowParent, clazz, modal));
PopUpManager.centerPopUp(p);
return p;
}
_windowParent is a reference to the application's WindowedApplication root object. I'm running into two kinds of problems with this:
Not all popups appear modal, even if I set the modal parameter to true. This seems to happen if I open a popup panel from within another popup panel.
In some of the popup panels are ComboBoxes and the popdown menu of the comboboxes opens underneath of their parent panel (i.e. under the depth of the panel) so the menu of the combobox becomes partly or fully obstructed.
I've tried different parameters for the PopUpManager.createPopUp() childList parameter (e.g. PopUpManagerChildList.APPLICATION) but that did not change anything.
Hoping that anyone has some tips on these problems!

Nevermind! Figured out I some code that would change the depth of panels that was messing this up.

Related

Google VR Reticle Click on UI Button

So I am having this issue with using Google VR reticle where I cannot click a button. I have an image attached showing the heirarchy and the PlayButton is what I am trying to click. The Canvas has a Graphic Raycaster, the button has an Event Trigger that calls the method to navigate to the next scene. The UpScrollPanel, and DownScrollPanel work just fine. The EventSystem has the Gaze Input Module, as well as Event System, and Touch Input Module.
Any ideas on how to get this working? I have watched a few videos from NurFACEGAMES and while they helped a little, I haven't gotten the click to work yet.
Oh, and I am using Unity 5.3.4f
Sometimes things can get in the way of the button, make sure that no other UI elements overlap it, for example text borders (which are actually larger than they appear). You can also fix this by moving the button up the hierarchy among its siblings, I believe the first child is top.
Also try moving the button up the hierarchy if possible, sometimes UI having certain parents makes them not work
The canvas object should have a graphic raycaster
I found the issue to be unrelated to anything I thought it was. The menu I was using is a prefab I also use in another view that isn't VR. The scrollrect was loading that prefab, instead of the modified one I was using in the VR menu, and therefore the triggers I had added to the button were no being used when the app loaded.

How to update a QLayout and get the new dimensions before returning?

This is driving me nuts. I have a custom menu class that, when set visible, shows a list of items located in a particular folder. When a hardware button is pressed, my application gets the latest list of items, populates the menu with them, and returns.
The menu displaying these items uses a QListWidget filled with custom widgets. Each of the widgets contains one or more QLabels in a horizontal layout, and is created at the time the menu is shown. In order to adjust the text displayed based on the menu width available, I need to get the size of the QLabel AFTER it has been resized according to the layout, but before the menu becomes visible to the user. The problem is, my layout does not get updated until all of the functions constructing my list return.
I have tried QApplication::ProcessEvents() and the layout update functions, but none of them have updated the values of my QLabels before returning. I can set a QTimer when the button is initially pressed, and have it show the menu, update the items, and stop itself, but that seems like a terrible solution.
Any help would really be appreciated! I've spent most of a day on this.
Marlon
I had this exact problem and could not find an answer anywhere on the Internet. Calling Layout.update(), Layout.activate(), or widget.adjustSize() (all suggested in various places) all did not work.
I had a widget with a vertical layout that I wanted to add a QLabel to and then immediately use the size of the QLabel.
The only thing that worked reliably was
layout->addWidget(myLabel);
myLabel->show();
size = myLabel->size();
It would seem that layouts will just not recalculate until you either return from a function and allow the Qt event loop to progress or manually call show() yourself.
How to update a QLayout and get the new dimensions before returning?
Don't. You're not meant to do that. It'll drive you "nuts" because you're doing it backwards. Layout updates are handled asynchronously from the event loop. Instead of getting layout dimensions right away, set yourself up to be part of the system. Some options are:
Implement a custom widget that will interact properly with the layout, growing to fill the available width of the layout. Perhaps all you need is a size policy and a way to elide text?
Make a custom layout that takes the special properties of your use case into account.
You want to call QWidget::adjustSize() on your parent widget. This will force the layout recalculations.
Have you tried using layout()->update(); ?
I've tried many but nothing works for me on Qt 5.15.
Only invented little patch - create timer and get size after 20 msec:
QTimer::singleShot(20, this, [this]
{
const auto height = myLayout->contentsRect().height();
// ...
});

Flex form inside Pop up window - Tab (order) between forms not working

when user clicks on Add button, then a pop up button will be opened with certain form elements (like textinput, date field, text area).. When i used 'TAB' inside this form,it is not working. I found in couple of Questions / forums that we need to create an instance of FocusManager and then bring/activate focus for the pop up. But still i didn't see the tab working inside the form. In order to tab order working inside a pop up, what steps we need to follow.
I tried using focusmanager and property like tabfocusenabled, tabenabled and also added taborder inside each form element. But no luck.
Iam using Flash Builder 4.5 and using spark components for development.
Is there any workaround for this problem?
Thanks in Advance,
Regards
Srinivasan
Thanks for all your responses.
Finally the issue has been solved by one of my colleague. Problem is , the form has been loaded inside Horizontal accordion (flexlib HACCORDION). So inorder to draw focus inside the accordion to child elements, we need to add 'hasFocusableChildren="true"' for the HAccordion (horizontal accordion component). Adding this property solves the tab order problem.
I have also pasted the code below:

Make a Spark TitleWindow modal without using much AS3?

I want to be able to show a Spark TitleWindow container as a modal without having to construct it by code via AS3. I tried creating the TitleWindow before-hand manually by dragging and resizing it around and adding objects, etc then hiding it. Then on a button, I set the called function to the ones below:
public function doPopup():void {
testWindow.visible = true;
PopUpManager.addPopUp(testWindow, this, true);
}
Unfortunately, this only shows testWindow but not as a modal. I want it to be like this so that I can freely resize and design the layout of my TitleWindow and only have to call some function to show it as a modal one.
I'm pretty sure the reason you are seeing this behavior is because your TitleWindow (that you've declared within the mxml of the parent container) is already added to the stage even though it is set as not visible. A workaround you could try is to call this.removeElement(testWindow) in a creation complete handler for the parent container. That will get it off the stage so the PopUpManager can add it later properly.
Having said that, I would recommend putting your TitleWindow into a separate mxml file and instantiate it using the PopUpManager. It's cleaner that way and you can still use the design mode to lay it out as you see fit.
Hope that helps.
Try the Cairngorm 3 Popup library :
http://opensource.adobe.com/wiki/display/cairngorm/HowToUseCairngormPopup

most rational way to drag popup menu in flex

In my app I currently have a popup menu implemented as a BorderContainer with a lot of buttons, textfields, date pickers, etc. PopUpManager handles its appearing and disappearing based on some UI events.
I'd like to be able to drag the container by clicking on any part of it minus all the components on it. In other words, when I click on buttons, text fields, etc. I'd like for them to respond as usual and for the container not be draggable.
I've tried this very simple implementation
_menu.addEventListener(MouseEvent.ROLL_OVER, toggleDragON);
_menu.addEventListener(MouseEvent.ROLL_OUT, toggleDragOFF);
private function mouseDown(event:MouseEvent):void
{
_menu.startDrag();
}
private function mouseReleased(event:MouseEvent):void
{
_menu.stopDrag();
}
but this definitely doesn't do the trick, i.e. all components lead to dragging. I've tried to make sure that mouseEnabled and mouseChildren are true for all the components but this doesn't seem to make any difference.
I then came across this thread which makes a lot of sense, but I have a hard time believing that the best way for one to handle this is to handle all click events for each of the components on the popup. Is there an obviously simple way to do this that I'm missing?
thank you!
f
How about checking the target property of the event to check if it equals your menu?
if (event.target == _menu) {
_menu.startDrag();
}

Resources