summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-11-12 12:28:16 +0100
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2014-11-13 20:03:30 +0100
commitc506d938a83585d973cbc369e99503cf83db68e2 (patch)
tree81cbbb15be464629e85c75df09935c2465d7a816 /src/plugins
parentbed25d8a3a27a439e5a50083be6b7218a8982d3c (diff)
iOS: close menu when keyboard hides
If the menu is closed from the keyboard gesture, and the focus object doesn't change, the menu will still be in a visible state, even if the keyboard is hidden. This patch will ensure that this can not be the case by listening for keyboardWillHideNotification. Since we have no guarantee for when the destructor runs, we apply a pessimistic approach and ensure we stop listen when the menu gets closed. Task-number: QTBUG-42523 Change-Id: If734ea32d1823b978c9c1c67ebcc5b6c3c5c338c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index f64c1a2f41..0f351f785b 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -153,13 +153,29 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[self setDelegate:self];
[self setDataSource:self];
[self selectRow:m_selectedRow inComponent:0 animated:false];
+ [self listenForKeyboardWillHideNotification:YES];
}
return self;
}
+-(void)listenForKeyboardWillHideNotification:(BOOL)listen
+{
+ if (listen) {
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(cancelMenu)
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ } else {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ }
+}
+
-(void)dealloc
{
+ [self listenForKeyboardWillHideNotification:NO];
self.toolbar = 0;
[super dealloc];
}
@@ -193,6 +209,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)closeMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
if (!m_visibleMenuItems.isEmpty())
QIOSMenu::currentMenu()->handleItemSelected(m_visibleMenuItems.at(m_selectedRow));
else
@@ -201,6 +218,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)cancelMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
QIOSMenu::currentMenu()->dismiss();
}