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

Window content not visible in full screen mode on Cocoa #2796

Closed
freakboy3742 opened this issue Aug 29, 2024 · 3 comments
Closed

Window content not visible in full screen mode on Cocoa #2796

freakboy3742 opened this issue Aug 29, 2024 · 3 comments

Comments

@freakboy3742
Copy link
Member

Originally posted by @proneon267 in #2473 (comment)

On macOS, if the content of the window is a toga.Box(), and the window is made full screen (full app-level presentation mode, not window-level full-screen), the window content is not visible.

If main_window.content is a toga.Box:

"""
My first application
"""

import toga

class HelloWorld(toga.App):
    def handle_press(self,widget,**kwargs):
        self.set_full_screen(self.main_window)
        self.main_window.content.add(toga.Label(text="We are in App Full Screen mode"))
        print(f"Subviews After App Full Screen:{self.main_window._impl.native.contentView.subviews}")
        
    def startup(self):
        """Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = toga.Box(children=[
            toga.Button(text="Enter App Full Screen Mode",on_press=self.handle_press),
            toga.Label(
                text=""" Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"""
                     """ Maecenas vitae felis non est vehicula pulvinar id eu augue.\n"""
                     """ Maecenas et lectus tellus. Sed et lacinia erat, at pharetra quam.\n"""
                     )
        ])
        self.main_window.show()
        print(f"Subviews Before App Full Screen:{self.main_window._impl.native.contentView.subviews}")


def main():
    return HelloWorld()

image

After entering app full screen mode:
Screenshot 2024-08-29 at 8 46 36 AM

The children of the toga.Box() are not visible after entering full screen.

However, if the main_window.content is a toga.ScrollContainer then it works correctly:

"""
My first application
"""

import toga

class HelloWorld(toga.App):
    def handle_press(self,widget,**kwargs):
        self.set_full_screen(self.main_window)
        self.main_window.content.content.add(toga.Label(text="We are in App Full Screen mode"))
        print(f"Subviews After App Full Screen:{self.main_window._impl.native.contentView.subviews}")
        
    def startup(self):
        """Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = toga.ScrollContainer(content=toga.Box(children=[
            toga.Button(text="Enter App Full Screen Mode",on_press=self.handle_press),
            toga.Label(
                text=""" Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"""
                     """ Maecenas vitae felis non est vehicula pulvinar id eu augue.\n"""
                     """ Maecenas et lectus tellus. Sed et lacinia erat, at pharetra quam.\n"""
                     )
        ]))
        self.main_window.show()
        print(f"Subviews Before App Full Screen:{self.main_window._impl.native.contentView.subviews}")


def main():
    return HelloWorld()

Screenshot 2024-08-29 at 8 49 28 AM

The children are being added properly as indicated by the subviews, but they are not visible when content is a toga.Box()

@freakboy3742
Copy link
Member Author

My guess is that the problem will be a layout issue - when going full screen, the "window" is possible reporting as "zero sized" (either temporarily or permanently), resulting in an incorrect layout for window content.

@proneon267
Copy link
Contributor

Thanks for shifting it here. I'll look into this and report back.

@freakboy3742
Copy link
Member Author

Fixed by #2800.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants