Can't re-open a Qt app if I reimplement QCloseEvent - macos

I'm trying to let the app hide to dock when user click on the close button.
So I implemented QCloseEvent:
void xxx::closeEvent (QCloseEvent *e)
{
hide ();
e->ignore ();
}
Now if I click on close button, it works but I can never bring it back
Nothing happens when I click on the dock
I guess I'm missing an event? What should I do now?

Related

Windows 10 UWP app - Back button only works when pressed the second time

I am developing a Windows 10 UWP app with Visual Studio 2015. I am working on the back button functionality right now. Unfortunately there is a problem. When I press the back button (either on a Phone or on the PC) it doesn't go back to the previous page. When I press it again it works.
It is like this example:
Start App (page 1)
Go to page 2
Go to page 3
Click back button (nothing happens)
Click back button (it goes to page 2)
Click back button (it goes to page 1)
So the first time when you want to go back it needs two presses... why? Additionally I've found out that the first press doesn't trigger the back button event. But why?
I am using the implementation as described in this article:
http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps
It has to do with SplitView staying open and holding the back event. You should close it if you are using it as overlay.
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
this.SplitView.IsPaneOpen = false;
Frame.Navigate(typeof(SettingsPage));
}

Sencha Touch - Windows Phone 8 Phonegap Application Bar not hiding on back button click

We are developing an hybrid mobile application using Sencha touch 2 for Windows Phone 8.
While developing we noticed that for a number field in windows phone 8 there is no keyboard done button available.Please refer to the below screenshot.
We then decided to write a custom application bar in Windows Phone 8 - Phonegap application inside the MainPage.cs with an Done button inside that application bar.Please refer to the below screenshot.
Now the done functionality works fine but when we click on the back button of the device the keyboard hides but the application bar remains in the view as in the below screenshot
We tried overriding the back button functionality in phonegap, but when the keyboard is shown the back button click is fired only the second click ,the first click hides the keyboard and the second click fires the overridden function.
Can someone provide some alternatives or a solution on how to hide the custom application bar along with the keyboard when the back button is clicked the first time ?
In MainPage.xaml.cs add listener mentioned below which listens the event when back button is pressed in device when keypad is opened.
And pass a string from java script when ur calling particular plugin to show the application bar contains done button, by using that you can identify in which case you have to show and other case you can hide the bar.
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneShow", "Num");
cordova.exec(null, null, "Cordova.Extension.Commands.DoneButtonPlugin", "keyboardDoneHide", "input string");
private void CordovaView_LayoutUpdated(object sender, EventArgs e)
{
if (CordovaView.Content.DesiredSize.Height == 0)
{
if(App.appBar.IsVisible)
App.HideShell();
}
else
{
if (App.NumKey == "\"Num\"") {
if(!App.appBar.IsVisible)
App.ShowShell();
}
}
}

Menu closes during Drag and Drop with NSStatusItem

This question is in response to Drag and Drop with NSStatusItem
The code from #rob Keniger works for me. Following these exact steps, When I run the app, click the menu bar icon, I can drag things to my drag area and everything works. My problem is if I run the app, (then instead of clicking the menu icon first) click Finder, then click the menu bar icon, when I try to drag, the menu closes as I'm dragging.
How do I make the menu view stay open every time the user has the menu open and is dragging?
Looks like you have to do this:
[NSApp activateIgnoringOtherApps:YES];

Pressing the device's back button do we have to close the Message box and cancel the backwards navigation too in WP7?

In the Certification guidelines 5.2.4 C they mentioned that if the current page displays a context menu or a dialog, the pressing of the Back button must close the menu or dialog and cancel the backward navigation to the previous page.
Is this applicable for MessageBox also?
I am using MessageBox to prompt the user to allow the location service api to use location i.e. lat and long which is in application launching.
Do I have to follow the 5.2.4 C for the MessageBox too be closed and stop back navigation.
Please guide me for standard way to implement so not to fail in Windows phone 7 Certification process.
4.Check the Back button Twice:
protected override void OnBackKeyPress( System.ComponentModel.CancelEventArgs e )
{
if (DemoPopup.isOpen)
{
e.Cancel = true;
//hide the popup
DemoPopup.IsOpen = false;
}
else
{
base.OnBackKeyPress(e);
}
}
Yes, if you have a Message Box displayed (or a Context Menu) then pressing the back button should dismiss the Message Box instead of navigating backwards, i.e. backwards navigation should not occur.
However, in the case of MessageBox.Show and ContextMenu (from the Silverlight Toolkit), I think this happens for you automatically.

How do you make the Application window open when the dock icon is clicked?

I'm surprised this doesn't happen automatically, but I would like my applications window to open automatically when the Dock icon is clicked.
Just to clarify, when i open the app, the window automatically opens, but when I click the cross for the window but leave the App running, the window won't open when i click the dock icon.
Implement - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag in your app delegate. Check the documentation for the details of the return value.
Document based apps and non-document based apps behave slightly differently. If there are no open windows when the dock icon of a document based app is clicked then it will create a new document. If there are no open windows when the dock icon of a non-document based app is clicked then it will do nothing.
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if (flag) {
return NO;
}
else
{
[YourWindow makeKeyAndOrderFront:self];// Window that you want open while click on dock app icon
return YES;
}
}
This is what I'm doing to get the main window of a non-document based app back to screen once it has been closed. I know this might not be the right way to do it but It's working for me so far.
Implemented this on the AppDelegate, window is defined as instance variable of the same object.
- (BOOL) applicationShouldOpenUntitledFile:(NSApplication *)sender
{
[window makeKeyAndOrderFront:self];
return NO;
}
If anyone has a better solution please reply. Thanks!
As others pointed, using applicationShouldHandleReopen method for reopening closed windows in non-document apps is the right way. The only change I want to add is a more flexible way to check what window must be re-displayed, by iterating through the NSApplication's list of visible and invisible .windows and checking for the required window.
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if flag == false {
for window in sender.windows {
if (window.delegate?.isKind(of: WelcomeWindowController.self)) == true {
window.makeKeyAndOrderFront(self)
}
}
}
return true
}
Appendix
a) If window was hidden then it will be showed automatically when user will click on app's Dock icon, so no need to implement applicationShouldHandleReopen method.
b) Checked "Release when closed" option doesn't affect in any way the above behaviour.
A document based application will automatically open a new untitled document when the app becomes active, so I am assuming you are referring to a non-document based app.
Implement the applicationDidBecomeActive: method in your application delegate and open/show the window.
Edit:
Some information on Delegates.
Some information on Opening and Closing Windows and the NSWindow API
A solutions to add to the accepted answer:
With the accepted answer the reopened window did not react to mouse events anymore.
When using the accepted answer you also have to make sure to uncheck "Release when closed" in the Attributes Inspector of the window in IB. This fixes the unresponsive window problem.
https://developer.apple.com/forums/thread/706772?answerId=715063022#715063022
func applicationDidFinishLaunching(_ aNotification: Notification)
{
NSApplication.shared.delegate = self
}
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
//Now is working
return true
}

Resources