mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
remove focus from active text input after keyboard is closed
allows focusing same text input again kambala-decapitator/vcmi#4 kambala-decapitator/vcmi#10
This commit is contained in:
parent
27b7cb8f1f
commit
44d0e19c71
21
client/CFocusableHelper.cpp
Normal file
21
client/CFocusableHelper.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* CFocusableHelper.cpp, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#include "CFocusableHelper.h"
|
||||
#include "../Global.h"
|
||||
#include "widgets/TextControls.h"
|
||||
|
||||
void removeFocusFromActiveInput()
|
||||
{
|
||||
if(CFocusable::inputWithFocus == nullptr)
|
||||
return;
|
||||
CFocusable::inputWithFocus->focus = false;
|
||||
CFocusable::inputWithFocus->redraw();
|
||||
CFocusable::inputWithFocus = nullptr;
|
||||
}
|
11
client/CFocusableHelper.h
Normal file
11
client/CFocusableHelper.h
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* CFocusableHelper.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
void removeFocusFromActiveInput();
|
@ -145,6 +145,16 @@ set(client_HEADERS
|
||||
SDLRWwrapper.h
|
||||
)
|
||||
|
||||
if(APPLE_IOS)
|
||||
set(client_SRCS ${client_SRCS}
|
||||
SDL_uikit_main.mm
|
||||
CFocusableHelper.cpp
|
||||
)
|
||||
set(client_HEADERS ${client_HEADERS}
|
||||
CFocusableHelper.h
|
||||
)
|
||||
endif()
|
||||
|
||||
assign_source_group(${client_SRCS} ${client_HEADERS} VCMI_client.rc)
|
||||
|
||||
if(ANDROID) # android needs client/server to be libraries, not executables, so we can't reuse the build part of this script
|
||||
@ -153,8 +163,6 @@ endif()
|
||||
|
||||
if(WIN32)
|
||||
set(client_ICON "VCMI_client.rc")
|
||||
elseif(APPLE_IOS)
|
||||
set(client_SRCS ${client_SRCS} SDL_uikit_main.m)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DEBUG_CONSOLE)
|
||||
|
@ -8,9 +8,11 @@
|
||||
#include <SDL_events.h>
|
||||
#include <SDL_render.h>
|
||||
|
||||
@import UIKit;
|
||||
#include "../Global.h"
|
||||
#include "CMT.h"
|
||||
#include "CFocusableHelper.h"
|
||||
|
||||
extern SDL_Window * mainWindow;
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@interface SDLViewObserver : NSObject
|
||||
@ -89,6 +91,9 @@ main(int argc, char *argv[])
|
||||
[NSNotificationCenter.defaultCenter addObserverForName:UIWindowDidBecomeKeyNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||
[UIApplication.sharedApplication.keyWindow.rootViewController addObserver:observer forKeyPath:NSStringFromSelector(@selector(view)) options:NSKeyValueObservingOptionNew context:NULL];
|
||||
}];
|
||||
[NSNotificationCenter.defaultCenter addObserverForName:UIKeyboardDidHideNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
||||
removeFocusFromActiveInput();
|
||||
}];
|
||||
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user