Skip to content

Commit

Permalink
Merge pull request #4842 from JakubValtar/fix-sketchbook-update
Browse files Browse the repository at this point in the history
Rebuild sketchbook window when needed
  • Loading branch information
benfry committed Jan 29, 2017
2 parents 2fb23f6 + 7b8f307 commit af392ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
19 changes: 14 additions & 5 deletions app/src/processing/app/Mode.java
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ public void rebuildExamplesFrame() {
if (visible) {
bounds = examplesFrame.getBounds();
examplesFrame.setVisible(false);
examplesFrame.dispose();
}
examplesFrame = null;
if (visible) {
Expand Down Expand Up @@ -691,11 +692,19 @@ public DefaultMutableTreeNode buildSketchbookTree() {

/** Sketchbook has changed, update it on next viewing. */
public void rebuildSketchbookFrame() {
boolean wasVisible =
(sketchbookFrame == null) ? false : sketchbookFrame.isVisible();
sketchbookFrame = null; // Force a rebuild
if (wasVisible) {
showSketchbookFrame();
if (sketchbookFrame != null) {
boolean visible = sketchbookFrame.isVisible();
Rectangle bounds = null;
if (visible) {
bounds = sketchbookFrame.getBounds();
sketchbookFrame.setVisible(false);
sketchbookFrame.dispose();
}
sketchbookFrame = null;
if (visible) {
showSketchbookFrame();
sketchbookFrame.setBounds(bounds);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,10 @@ public void handleDeleteCode() {
// get the changes into the sketchbook menu
//sketchbook.rebuildMenus();

// make a new sketch, and i think this will rebuild the sketch menu
// make a new sketch and rebuild the sketch menu
//editor.handleNewUnchecked();
//editor.handleClose2();
editor.getBase().rebuildSketchbookMenus();
editor.getBase().handleClose(editor, false);

} else {
Expand Down

0 comments on commit af392ae

Please sign in to comment.