M
M
Maxim Samoilov2014-07-08 19:20:12
Cocoa
Maxim Samoilov, 2014-07-08 19:20:12

How to bring a window to the front programmatically?

Created a CheckBox to enable / disable the display of the program in the Dock, but when the program is hidden, all windows disappear.
I put Sent Action deminiaturize on the item in the bar menu: and the window appears when you click on this item,
but when you try to call [[self window] deminiaturize: self]; in the code - nothing happens.

-(void)changeDockVisible:(id)sender {
    if ([NSApp activationPolicy] == NSApplicationActivationPolicyRegular) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:NVHideDockIcon];
        [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
        // Здесь окна программы исчезают, пока не нажму на пункт в меню баре
    } else {
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:NVHideDockIcon];
        [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
    }
}

9fdfbcf00069ab6480f5d799d87b8046.gif

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question