Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 18.0.0 bug. #553

Closed
pnahay opened this issue Apr 5, 2022 · 28 comments · Fixed by #593
Closed

Version 18.0.0 bug. #553

pnahay opened this issue Apr 5, 2022 · 28 comments · Fixed by #593
Labels
bug Something isn't working

Comments

@pnahay
Copy link

pnahay commented Apr 5, 2022

Product Version
JavaFX Scene Builder 18.0.0

Build Information
Version 18.0.0
Date: 2022-03-31 20:20:30
JavaFX Version: 18
Java Version: 17, OpenJDK Runtime Environment

Expected Behavior

Ctrl+P should invoke menu command "Show Preview in Window".

Current Behavior

Ctrl+P does nothing.

Steps to Reproduce

Invoke Ctrl+P.

Your Environment

Windows 10.

Screenshots

@pnahay pnahay added the bug Something isn't working label Apr 5, 2022
@Oliver-Loeffler
Copy link
Collaborator

Hi @pnahay , I've tested it with current Scene Builder 19 Snapshot version on Win10 21H2 and also with the SB18 version as released before April. In both cases I was unfortunately not able to reproduce the isse.

Can you please share more details?
Did you install from MSI file, did you ran Scene Builder from project?

@pnahay
Copy link
Author

pnahay commented Oct 1, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Hi @pnahay,
this helps a little. Well, there is no need to share the original file. If you could create another FXML file with a structrue which also creates the behavior, that would help a lot.

If you are using some kind of dynamic elements or custom values or includes inside the FXML, try to replace them with artificial content not related to the issue. An example showing the behavior would be great. One approach would be to take a working example and modify it step by step to reach the point where Scene Builder breaks or vice versa by taking content away from the questinable FXML until Scene Builder starts to work.

From that on, I would be able to create a test and possibly find a solution.

@pnahay
Copy link
Author

pnahay commented Oct 1, 2022 via email

@pnahay
Copy link
Author

pnahay commented Oct 1, 2022 via email

@pnahay
Copy link
Author

pnahay commented Oct 1, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Hi Paul, thanks!
Please add the file to the issue - seems that E-Mail attachments are not added to Github issues.

Thanks!
Oliver

@Oliver-Loeffler
Copy link
Collaborator

You can paste the FXML contents into a codeblock such as this one:

<FXML>
some contents...
</FXML>

Like that.

@Oliver-Loeffler
Copy link
Collaborator

Thanks for your support @pnahay , but those files did not arrive. Please just share the FXML #2 code here as plain text. This will be sufficient! Great weekend!

@Oliver-Loeffler
Copy link
Collaborator

Hi @pnahay
thanks for putting efforts into making this reproducible.
Can you please post the result of your investigations?
Would be great to have the FXML #2 for testing.
Otherwise, can you please describe what is different between the good and the failing FXML?

Thanks!

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Sorry. Well, I was more thinking on what the difference is inside the FXML, so the FXML code difference.
The FXML examples you've prepared are not accessible here. Could you please attach those example files here? Either FXML code directly or via link to e.g. pastebin.

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Oliver-Loeffler commented Oct 9, 2022

It seems if you just reply vie e-mail, the files are not attached to the Github issue. If you visit the Github website, navigate to the issue, then you can attach these files. With 'here' I am referring the Github Issue website at #553.

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022 via email

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022 via email

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022

Your ridiculous system won't allow me to attach an fxml file, so here's the content of the file that, when opened in SceneBuilder, won't allow the CTRL+P accelerator key combination to preview the file:

<GridPane alignment="CENTER" hgap="11.0" vgap="20.0" VBox.vgrow="NEVER">
	<columnConstraints>
		<ColumnConstraints halignment="RIGHT" maxWidth="541.0" minWidth="10.0" prefWidth="211.0" />
		<ColumnConstraints halignment="LEFT" maxWidth="867.0" minWidth="10.0" prefWidth="867.0" />
	</columnConstraints>
	<children>

		<Label styleClass="bbdlabel" stylesheets="@styles.css" text="ppppp ccccc:" GridPane.columnIndex="0" GridPane.rowIndex="0" />
		<Label fx:id="labelpppppccccc" contentDisplay="CENTER" prefHeight="57.0" prefWidth="875.0" styleClass="status" stylesheets="@styles.css" text="&lt;ppppp ccccc&gt;" GridPane.columnIndex="1" GridPane.rowIndex="0" />
		<!-- -->                        

		<Label styleClass="bbdlabel" stylesheets="@styles.css" text="mmmm ppppp:" GridPane.columnIndex="0" GridPane.rowIndex="1" />
		<Label fx:id="labelmmmmppppp" prefHeight="57.0" prefWidth="875.0" styleClass="status" stylesheets="@styles.css" text="&lt;mmmm ppppp&gt;" GridPane.columnIndex="1" GridPane.rowIndex="1" />
		<!-- -->            

	</children>
	<rowConstraints>
		<RowConstraints />
		<RowConstraints />
	</rowConstraints>
	<padding>
		<Insets top="22.0" />
	</padding>
</GridPane>

<HBox alignment="TOP_CENTER">
	<Canvas fx:id="canvasKC" height="120.0" width="1070.0">
    <HBox.margin>
       <Insets bottom="22.0" />
    </HBox.margin></Canvas>
	<VBox.margin>
		<Insets top="22.0" />
	</VBox.margin>
</HBox>

@pnahay
Copy link
Author

pnahay commented Oct 9, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Oliver-Loeffler commented Oct 10, 2022

Thanks for your efforts. Well, did not know that there is a file type limitation on Github.

Renaming files from FXML to TXT would have helped, also adding both files to a ZIP and attaching the ZIP would have worked.

I'll try with the snippets you provided.

@pnahay
Copy link
Author

pnahay commented Oct 11, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Very cool - I am able to reproduce the error. No clue why this happens yet but I'll figure out, Here is the FXML:

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.input.KeyCodeCombination?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="TOP_CENTER" xmlns="http://javafx.com/javafx/18"
  xmlns:fx="http://javafx.com/fxml/1"
  fx:controller="n.rrrrrrr.ControllerMain">
  <children>
    <MenuBar VBox.vgrow="NEVER">
      <menus>
        <Menu text="_File">
          <items>
            <MenuItem onAction="#onOpenFile" text="_Open File…">
              <accelerator>
                <KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem onAction="#onCloseFile" text="_Close..." />
            <SeparatorMenuItem mnemonicParsing="false" />
            <MenuItem onAction="#onFileProperties" text="File _Properties...">
              <accelerator>
                <KeyCodeCombination alt="UP" code="P" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem onAction="#onQuit" text="_Quit...">
              <accelerator>
                <KeyCodeCombination alt="UP" code="Q" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
          </items>
        </Menu>
        <Menu text="_per">
          <items>
            <MenuItem mnemonicParsing="false" onAction="#onGoToFirstxxxxxccccc" text="First xxxxx ccccc">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="HOME" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onGoToLastxxxxxccccc" text="Last xxxxx ccccc">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="END" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onGoToPreviousxxxxxccccc" text="Previous xxxxx ccccc">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="LEFT" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onGoToNextxxxxxccccc" text="Next xxxxx ccccc">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="RIGHT" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onGoToPreviousxxxxxcccccBar" text="Previous xxxxx ccccc bbb">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="PAGE_UP" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onGoToNextxxxxxcccccBar" text="Next xxxxx ccccc bbb">
              <accelerator>
                <KeyCodeCombination alt="ANY" code="PAGE_DOWN" control="UP" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem onAction="#onAllnnnnnOff" text="All nnnnn _Off">
              <accelerator>
                <KeyCodeCombination alt="UP" code="ESCAPE" control="ANY" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
            <MenuItem mnemonicParsing="false" onAction="#onPanic" text="Panic">
              <accelerator>
                <KeyCodeCombination alt="UP" code="SPACE" control="ANY" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
          </items>
        </Menu>
        <Menu text="_Setup">
          <items>
            <MenuItem onAction="#onDlgmmmmppppp" text="_mmmm ppppp...">
              <accelerator>
                <KeyCodeCombination alt="UP" code="M" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
              </accelerator>
            </MenuItem>
          </items>
        </Menu>
        <Menu text="_Help">
          <items>
            <MenuItem onAction="#onAboutrrrrrrr" text="_About rrrrrrr..." />
            <MenuItem mnemonicParsing="false" onAction="#onOpenHomePage" text="Open http://b.s" />
          </items>
        </Menu>
      </menus>
    </MenuBar>
    <FlowPane alignment="CENTER">
      <children>
        <Label fx:id="labelssssTitle" alignment="CENTER" styleClass="ssss-title" text="&lt;My Very, Very, Very, Very  Long ssss Title&gt;" textAlignment="CENTER" />
      </children>
      <VBox.margin>
        <Insets top="22.0" />
      </VBox.margin>
    </FlowPane>
  </children>
</VBox>

@pnahay
Copy link
Author

pnahay commented Oct 20, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Oliver-Loeffler commented Oct 20, 2022

The cause of the failing preview is, that Scene Builders preview accelerator CTRL+P is kind of shadowed by another accelerator definition inside the FXML. All accelerators inside the FXML are basically working. Not sure how to handle this.

Following FXML code makes the preview accelerator fail:

<MenuItem onAction="#onFileProperties" text="File _Properties...">
    <accelerator>
        <KeyCodeCombination alt="UP" code="P" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
    </accelerator>
</MenuItem>

The following setup will work fine:

<MenuItem onAction="#onFileProperties" text="File _Properties...">
    <accelerator>
        <KeyCodeCombination alt="UP" code="X" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
    </accelerator>
</MenuItem>

Its as simple as either removing the accelerator at all or mapping it on another KeyCode. Nevertheless, this is an unaccaptable application behavior. I think it will be okay to capture the key events in a running preview but not in the editing view. The solution here might be either to capture the preview accelerator separately or even prevent accelerators in document window from being captured.
As a first step, I'll issue a PR to capture the preview accelerator separately.

@pnahay
Copy link
Author

pnahay commented Oct 20, 2022 via email

@Oliver-Loeffler
Copy link
Collaborator

Please test PR #593 if this would work for you. As of now I definitely read more into the Scene Builder and JavaFX code to find a better solution for this issue.

@Oliver-Loeffler
Copy link
Collaborator

@pnahay Which points are confusing? Thats something which potentially could be improved.

@pnahay
Copy link
Author

pnahay commented Oct 20, 2022 via email

@pnahay
Copy link
Author

pnahay commented Oct 20, 2022 via email

Oliver-Loeffler added a commit that referenced this issue Nov 10, 2024
… in FXML (#553) (#593)

* fix: Prevents CTRL+P from being masked by a given accelerator defined in FXML. Hence allowing to show preview with CTRL+P.
* Added showPreview method to MenuBarController.
* Key code provided by event is now compared to KeyCode instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants