Disable interaction with main window, while other window is open - objective-c

I have a main window where all the work is done.
When i open the preference panel I would like to freeze the main windows as long as the preference panel is open.
For example iTunes: as soon as i open the preferences i just can interact with preference panel and nothing else.
Is there an easy way to archive this behavior?

Code:
[NSApp runModalForWindow:theWindow];

Related

Open window such that is shows on all desktops

I have a screenshot thing, what it does is it takes a screenshot of the current visible stuff, then opens a full screen window covering everything. However this opens on the desktop of the parent window which is on desktop 1. And if a user had desktop 2 focused (due to like fullscreen app or something) then the window that opened will not show on desktop 2.
So I was wondering if there is a window level or something (I tried all the window levels) that will make it such that a window appears on all desktops.
Thanks
This sounds like either NSWindowCollectionBehaviorCanJoinAllSpaces or NSWindowCollectionBehaviorStationary. Set it as the collectionBehavior of the window.
(You probably want to set the window level, too, but that's about ordering rather than collection/Spaces behavior. And if you have a Window menu, then you probably also want NSWindowCollectionBehaviorIgnoresCycle.)

Windows 8 tablet - How to prevent explorer from starting desktop app with maximized window?

When I start a desktop application on Windows 8 tablet, Explorer starts it with SW_SHOWMAXIMIZED.
For example, if you start Notepad from command prompt, it opens in normal window size, but if you do that from Explorer, maximized window is opened. I have seen this Explorer behavior only on tablet PC and I guess Explorer is doing that on purpose.
I understand that it may be useful for many application programs, but I want my program to start with normal size unless user explicitly requests Explorer to open it maximized.
Is there a way to stop this for my application? I'm hoping that there is an API or manifest to do that, but I couldn't find any information at MSDN.
Thanks in advance.
See if this helps:
Open any program that is affected with this issue. Note: Make sure that it is the only open window of that program. eg. You can only do this if you have one window of command prompt open.
Adjust the window size and position to your liking.
While holding Ctrl on your keyboard, close the window by clicking (or touching, for tablet) the X in the top-right corner of the window to close it.
Re-open the program. Your window should now open in the way you set it in step 3.

Detect Settings Charm is Opened or Not in Windows Store Apps?

I just want to know is that Any other way to get the Settings Charm is active or not.
Because, In my app, the Settings of an app is in the settings charm(If user presses Settings btn in App will leads to open Settings Charm)
In my case, Instead of using the settings btn. user may use short cut (WIN + C) (or) Moving the Mouse to the Right corner of the Screen. to enter into the settings pane means how could i know that?
Is that any way to find that????
Tap in to CommandsRequested on the SettingsPane
Occurs when the user opens the settings pane. Listening for this event lets the app
initialize the setting commands and pause its UI until the user closes the pane.
Now detecting that it's closed again would amount to checking that your window is again activated - see this thread.

GTK builder: Empty dialog window after WM-kill

I used glade to build my GUI.
Now i have a transient top level dialog window that pops up. If i kill this dialog window with a window manager shortcut, it gets deleted/destroyed. I catch those signals an do a dialog_window.hide() but if i reopen the dialog window an empty window appears.
Am i missing some glade settings?
Or do i have to rebuild the dialog window each time? - When yes, how?
Here is my glade-file: http://codepad.org/dP7NOlob
The window i'm talking about is named edit_account_window
If the WindowManager kills the window all widgets get deleted, so the window needs to be rebuild. This can be done like this:
def buildFooWindow(self):
self.builder.add_objects_from_file( 'glade_file_path', ['foo_window'] )
self.builder.connect_signals({'foo_window_cancel': self.fooWindowCancel})
So you have to call this function each time you want to show the window.

Closing frontmost window in Cocoa in an app without a menu bar

I am building a StatusBar App in Cocoa, therefore I have no menu. Having no menu implies not having a "File > Close" menu item, which normally listens to the shortcut "Command + W".
From my StatusBar App the user may open a window to change the preferences and that's where I'm running into problems: The user can only close the window by pressing the red dot with the mouse. However, like alle applications I want to support the "Command + W" shortcut as well.
At the moment I see two possibilities to solve this issue:
Place an invisible button on the window which listens to the shortcut.
Add an application-wide listener for the shortcut and contact the window manually.
Both solutions feel like a misuse of the system. The first solution can lead to unexpected behaviour (the window closes if the user hits the invisible button by chance) and the second solution will still result in a beep, since the window does not know that it handles such a shortcut.
Is there an elegant way to solve this problem? Since the view should know what to do, a solution with just Interface Builder would be perfect. If there is no elegant way, is there a way to enhance the solutions mentioned?
Thanks in advance!
If you put a File > Close menu item in your MainMenu nib, the shortcut will work, even though the menu isn't visible.
If you choose to implement an app-wide listener for the shortcut instead, you can get rid of the beep by returning nil from the block, so that the original event doesn't get passed on.