Changing the size of a window on button click

Hi,

I have created a window with frame parameters height and width as 300x300 respectively. I would like to expand the window to 300x600 or something similar upon the click of button.

I have setup the button, but I am not able to change the window size dynamically. Any pointers?

Best,

Vishnu

What have you tried? Can we see your code?

I am quite new to swift, so I tried changing the frame() width and height of the VStack in which the button/text is defined. I tried googling this particular feature but I could only find resizing images and not the whole window itself. If you could point me to any resources, that also would be great as I could not find any.

My end goal is to increase the window size as the text contents displayed keep increasing. If there is no text then the default window size should remain as small as possible. Currently I have set the window size as follows


    

    

    var body: some Scene {

        

        WindowGroup {

            ContentView()

                .navigationTitle("Firmware Utility")

                .frame(width:300,height:300)

        }

        .windowResizability(WindowResizability.contentSize)



    }

}

even if I remove the line of code

 .windowResizability(WindowResizability.contentSize)

my window still does not expand as the text shown piles up. I asked for a button based event because it is easier to build up my end goal from there.

thanks.

Changing the size of a window on button click
 
 
Q