My app uses two displays (screen(0) and screen(1)). Screen(0) is the main screen and has the menubar. I have configured screen(1) for no menubar. My app starts by displaying a window in screen(0) and then displaying a window in screen(1).
The app then sits waiting for the user to do something.
If the user then selects from the menubar, an item that triggers an OpenDialog command, the Open-file dialog box appears on screen(1).
How do I force the dialog box to display in screen(0) (i.e., the main screen)?
Thank you in advance for any suggestions/input.
FWIW, I notice that when I use a keyboard shortcut to display the launchpad, that it also shows up on the second display and not the main display
If your app window is active on screen(1) the OS has determined that was the last active screen, and your dialogs are going to open there. I’m not entirely sure you’re going to be able to control which screen the dialog opens on short of popping a new window on the main screen just before you open the dialog.
I tried that. I have a dummy window that I show and force onto the Main Screen, which is the location of the MainWindow.
I then close the window.
That did not force the app back to Screen(0).
The app did perform the way I want it to if I first click on the MainWindow to bring it to the front. So I think what Ian really asking for is how can I bring the MainWindow to the front via code.
I saw something in the forum regarding bringing a window to the front, but I couldn’t get the solution suggested by Kem Tekinay to work (Pasted below)
[i]Kem Tekinay 20 Mar 2014 Alpha Testers, Beta Testers, Xojo Pro New York
It took a little looking around, but I found it in MacOSLib. Here is the code with that package installed:
dim nsw as NSWindow = windowToActivate
dim cntrl as new NSWindowController( nsw )
cntrl.ShowWindow
NSApplication.App.Activate( true )
Otherwise, look at the declares behind those calls.[/i]
Other solutions involve a third party MBS solution
Michel
I don’t really want to construct a window that will look like a standard dialog and I was unable to follow the solution posted by Axel Schneider.
I tried call a method that did this:
Declare Sub makeKeyAndOrderFront Lib “Cocoa” Selector “makeKeyAndOrderFront:” (NSWindow as Ptr)
makeKeyAndOrderFront(Ptr(self.handle))
where, self refers to the window I want to bring to the front.
I think makeKeyAndOrderFront is the sub I want, but I don’t think I am using it correctly. I am a bit of a novice in dealing with the Cocoa library and declare statements.
Any advice?
Thanks
Use Left & Top & position it however you want ?
Why aren’t you just calculating left & top so they’re on screen(0) and then show the thing ?
They’re settable property values
which will display the OpenDialog as a sheet window within my MainWindow. I think I can live with this as MainWindow is always located on Screen(0) and the user will not need to move the OpenDialog around