Opening secondary window in Java FX as child, forces overlap - anyway to overcome it? - javafx-8

I am attempting a simple app in Java FX 8 where I will have a window which is the main application and presents a list of to-do's.
When you select a to-do it opens a child window related to the to-do that was opened.
However, the child window will always be in front of the parent (unless side by side), but I will allow opening multiple windows, and navigation back to the parent.
Is there a way to allow the parent to become fully in view while still having the secondary window as a child?
Sample code:
Scene secondScene = new Scene(root, 800, 400);
Stage secondStage = new Stage();
secondStage.setTitle("Your to-do.....");
secondStage.setScene(secondScene);
secondStage.initStyle(StageStyle.DECORATED);
secondStage.initModality(Modality.NONE);
secondStage.initOwner(primaryStage);
primaryStage.toFront();
secondStage.show();

Did you already try secondStage.setAlwaysOnTop(false)? I'd assume it's true by default, that's why the behaviour.

You could use:
secondStage.initModality(Modality.APPLICATION_MODAL);
You can find a reference here: http://docs.oracle.com/javafx/2/api/javafx/stage/Modality.html

Related

e4 RCP: programmatically open part in new window

I would like to programmatically open an MPart in a new MWindow.
Similar to as if I would create the part in a partstack somewhere in the existing window and then manually drag it away with the mouse.
So, one way would be to create a non-rendered window which contains this part. And once it should be shown, we can set it to being rendered. But: once we close this window, we cannot bring it back?!
This approach worked for me:
Define an empty window in the e4xmi which is set to not be rendered
Once we want to display the part, we create it (if it is not open already) and add it to the window
MUIElement window = modelService.find(myWindowId, app);
MPart part = (MPart) modelService.find(myPartId, application);
if (part == null) {
part = MBasicFactory.INSTANCE.createPart();
part.setLabel(ProcedureFlowChartPart.PART_TITLE);
part.setContributionURI("bundleclass://MyPartPath");
part.setElementId(myPartId);
((MWindow) window).getChildren().add(part);
}
partService.showPart(part, PartState.ACTIVATE);
window.setToBeRendered(true);
modelService.bringToTop(window);

Unity UI : How to reenable a dropdown after its panel was deactivated and then reactivated?

I am new to Unity, so this is probably a dumb question but here goes:
I have a Unity app; it has several scenes. One of those scenes has a Canvas upon which there are several overlapping Panels. On one of the Panels (PanelA), there is a Dropdown. When the app first runs PanelA is active and on top by default and the dropdown works fine. But after I deactivate PanelA with a C# call to
panelA.SetActive(false);// hides the panel
and then later reactivate it like so:
panelA.SetActive(true); // redisplays the panel
The dropdown no longer displays its list of option when clicked on. The dropdown is still there and still shows its first option "None" and when clicked on the drop-down changes color to indicate that it was touched, but the dropdown does not drop down its list of options.
What am I missing? Why doesn't the dropdown show the list of options?
Thanks
Windows 10 Pro v1709, unity 2017.1.1f1 Personal
My hierarchy is like so, PanelB is the panel that gets set active after PanelA is inactivated:
The script called when the dropdowns option is selected is called like so in Start():
PickDropDown.onValueChanged.AddListener(delegate {
myDropdownValueChangedHandler(PickDropDown);
});
and the called function is:
private void myDropdownValueChangedHandler(Dropdown target) {
Debug.Log("selected: "+target.value);
stage = 0;
currentval = PickDropDown.options [PickDropDown.value].text;
advice.text = "";
title.text = currentval;
if (currentval != NONE) {
advice.text = "You chose to do "+currentval;
nextVal();
}
}
void newVal(){
Debug.Log("newVal " );
PanelA.SetActive (true);
PanelB.SetActive (false);
Debug.Log("options count="+ PickDropDown.options.Count );
}
void nextVal(){
Debug.Log("nextSet " );
PanelB.SetActive (true);
/*** next line shows the answer to my problem - from killer_mech **/
Destroy(PickDropDown.transform.Find("Dropdown List").gameObject);
/***************************************************************/
PanelA.SetActive (false);
}
Yes, this is a bug in unity. I can reproduce this now. This is happening because Unity is creating a game Object called "Dropdown List" inside dropdown which should get destroyed after the closing. But I have noticed a slight delay is happening while destroying(I used editor debug mode for this). When you set the game object active flag as false, it somehow stops the destroy object and results in object Dropdown List staying there so next time when you try to interact with it the object will still present. You will also notice a white box below the Dropdown list after this which indicates the dropdown list still is present.
For the solution what I did was just before I was about to turn my gameobject off I used
Destroy(PickDropDown.transform.Find("Dropdown List").gameObject);
Destroying this object solves the problem. I know this is not a good way to do it, but I checked whether any references to options are destroyed while destroying this which resulted in no error for me. And Dropdown creates new "Dropdown List" gameobject. So it is safe to assume that destroying is OK. Well not sure if any other good solution for this is out there but for now you can use this.
Note: I have tested this bug with Panel, Empty Gameobject as parent and finally with Dropdown
This shows what is happening inside the drop-down. 1) During No popup 2) During Open 3)After setactive off before the child is destroyed.

open and play a scene in Unity3d

I have done a project with many scenes in Unity3D.
In the first scene there are buttons, each of them will play a scene when clicked.
For example, if the player clicks the button “Show the balloon”, then the scene called Balloon (which contains a balloon object and its animation) will be opened.
How can I do it using JavaScript code?
See Application.LoadLevel(...).
From the documentation:
[...]. Before you can load a level you have to add it to the list of levels
used in the game. [...]
// Loads the level with index 0
Application.LoadLevel (0);
// Load the level named "HighScore".
Application.LoadLevel ("HighScore");
First thing you have to do is add all the levels you want into the Build Settings Property.
Go to Unity or File Menu, Build Settings, and drag and drop your scenes into the scroll window. Then it'll assign them a logical number (or you can reference by name).
Application.LoadLevel(0); // this loads the first level in the list
Application.LoadLevel("nameoflevel"); //does the same thing numerically except by name
Application.LoadLevel(Application.loadedLevel); //reloads current level
Application.LoadLevel(Application.loadedLevel + 1); //loads the next level in order
Application.LoadLevel(Application.loadedLevel - 1); //loads the prior level in order
Application.LoadLevel(Application.levelCount - 1); //loads the last level in list
The int version of LoadLevel takes the id from build settings.
You can also call the string version, which takes the scene name from the project view (Though it still has to be in build settings for it to be found)
Go to File->Build Settings and drag your scenes there then use following.
Application.LoadLevel("Ballon");
If you want to reload the current level, you can use
Application.LoadLevel (Application.loadedLevel);
You'll, of course, need to make sure to manually reset or destroy anything that was created by the scene and marked as DontDestroyOnLoad.
And yes, the only way to put levels in any order in your build is from the build settings menu. You can jump around to which level is loaded by specifying its name or build order, but if you wanted to insert your levels in order in the build sequence and just want to jump from one level to the next (ie, Menu->Level1->Level2->EndGame), you can use
Application.LoadLevel (Application.loadedLevel + 1);

gtkmm button not maintaining size and location

I have created two gtkmm button and added to HBox object. I called pack_end, and maintained the size as 21,20. But, the sizes are not maintained. Here is the code i have written and the window that i got while running the program.
Note: MYWindow is subclass of Gtk::Window
void MYWindow::customizeTitleBar()
{
//create a vertical box
Gtk::VBox *vBox = new Gtk::VBox(FALSE,0);
//create a horizontal box
Gtk::HBox *hBox = new Gtk::HBox(TRUE,0);
hBox->set_border_width(5);
//create title bar image
Gtk::Image *titleBarImage = new Gtk::Image("src/WindowTitleBar.png");
titleBarImage->set_alignment(Gtk::ALIGN_LEFT);
// hBox->pack_start(*titleBarImage,Gtk::PACK_EXPAND_WIDGET,0);
//create cloze button for window
mButtonClose = new Gtk::Button;
(*mButtonClose).set_size_request(21,20);
Gtk::Image *mImage = new Gtk::Image("src/Maximize.jpeg");
(*mButtonClose).add(*mImage);
(*mButtonClose).set_image_position(Gtk::POS_TOP);
// connecting close window function when cliked on close button
//(*mButtonClose).signal_clicked().connect( sigc::mem_fun(this, &MYWindow::closeWindow));
hBox->pack_end(*mButtonClose,Gtk::PACK_EXPAND_WIDGET,0);
Gtk::Button * mBtton = new Gtk::Button;
mBtton->set_size_request(21,20);
Gtk::Image *img = new Gtk::Image("src/Maximize.jpeg");
mBtton->add(*img);
mBtton->set_image_position(Gtk::POS_TOP);
hBox->pack_end(*mBtton,Gtk::PACK_EXPAND_WIDGET,0);
vBox->add(*hBox);
//drawing area box
Gtk::HBox *hBoxDrawingArea = new Gtk::HBox;
Gtk::DrawingArea *mDrawingArea = new Gtk::DrawingArea;
hBoxDrawingArea->pack_start(*mDrawingArea,Gtk::PACK_EXPAND_WIDGET,0);
vBox->add(*hBoxDrawingArea);
//status bar hBox
Gtk::HBox *hBoxStatusBar = new Gtk::HBox;
vBox->add(*hBoxStatusBar);
this->add(*vBox);
this->show_all();
}
I am not yet a gtk expert (but I'm learning), here's one thing you can try, which is what I've been doing.
Make a little standalone project using glade. Glade makes it really easy to screw around with all the packing settings so you can immediately see the effects of your changes.
I think in the case of resizing the window, you'll have to save the glade file and run your program (using gtkbuilder to render the glade file) and manually resize the window to see the effect, but once you make the standalone project, you can use it for other gtk testing.
And if you're like me, you'll get swayed by the wonderfulness that is glade and build your whole system that way.
But basically, it sounds like a packing issue, because I've got buttons that don't resize all over the place.
As for not moving, I'm not sure you can do that, but again I'm not an expert. I think you should be able to pin the size of some if not all of the hbox pieces so that the button inside them will not move, but I'm not sure what happens if you don't have any hbox parts that can't be variably sized to take up the slack when you grow the window.
Again, sounds like something fun to try in glade. :-)
I think you pack to FALSE , Maybe this is the problem :
Gtk::HBox *hBox = new Gtk::HBox(TRUE,0)
I use python gtk with something like this:
box1.pack_start(box2,False)

SWT: How to redisplay new contents of a CTabItem

I have a CTabFolder with one of its CTabItems which may change its contents on a given user action. But I don't know how to force the display once the contents have changed. I get the tab item blank; if I resize the window suddenly everything appears.
I'm not posting the code because I did some wrapping in Scala, but this is basically what I'm doing:
The CTabItem has a ScrolledComposite, set with setControl()
The ScrolledComposite contains a Composite
everything else is under this Composite
When the contents need to be changed, I take the existing CTabItem object, set it to a new ScrolledComposite, with a new Composite, from which hangs the new contents.
Calling redraw() and update() on the CTabFolder object doesn't do it... What should I do?
Thanks
Have you tried calling layout()?