I'm working with a multiple view project with FXML, generated by the Gluon plugin for IntelliJ.
When I navigate to the secondary view, coming from the primary view, and I push the back button on my physical android device, the view changes back to the primary view. This is normal behavior.
The problem is that the NavigationDrawer stays on the secondary view. You can observe this because you won't be able to navigate to the secondary view. When you push secondary in the navigation pane, nothing happens. This behavior is similar to trying to navigate to the page that you're currently on, which does also nothing.
Does anyone know a solution? Is this a bug? What's the best way to report bugs for Gluon because they wan't to move all support to SO?
The
NavigationDrawer
basically is a popup with a list of items, where usually each of these items allows the selection of aView
.If views can only be accessed through the drawer, then you won't have any issue, given that always the selected item will be related to the active view.
The issue you are having occurs when you access views by other means, like the back button.
By default, the drawer list doesn't track the active view to auto select the related item. If later, you try to select an item that is already selected, the listener won't fire the switch of views.
While this could be done internally by the control (incoming versions will probably manage that), it's easy to achieve.
Just add a listener to
viewProperty()
on your main class, and whenever the view changes, update the selected item on the drawer. Since this will trigger a change in thenavigationDrawer.selectedItemProperty()
, before updating the selection, we need to remove the listener, and add it again.