iOS: notify application when edit menu is closed

The edit menu will also close if the user taps outside it, not only
when selecting a menu item. But we never caught this case, which left
QMenu to belive that it was still open.

Change-Id: Iae071b4fc5fdc44d7d05b4dd767042907e337957
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Richard Moe Gustavsen 2015-12-16 23:38:13 +01:00 committed by Richard Moe Gustavsen
parent e362774df2
commit bace82bffe

View File

@ -61,11 +61,23 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
{
if (self = [super init]) {
[self setVisibleMenuItems:visibleMenuItems];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(menuClosed)
name:UIMenuControllerDidHideMenuNotification object:nil];
}
return self;
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:UIMenuControllerDidHideMenuNotification object:nil];
[super dealloc];
}
- (void)setVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems
{
m_visibleMenuItems = visibleMenuItems;
@ -85,6 +97,11 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:NO];
}
-(void)menuClosed
{
QIOSMenu::currentMenu()->dismiss();
}
- (id)targetForAction:(SEL)action withSender:(id)sender
{
Q_UNUSED(sender);