mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
SDL: Fix can't input text fields in the main menu
This commit is contained in:
parent
09445f294c
commit
3a2c469c99
@ -704,7 +704,7 @@ void LBackend_InputSelect(struct LInput* w, int idx, cc_bool wasSelected) {
|
|||||||
LInput_MoveCaretToCursor(w, idx);
|
LInput_MoveCaretToCursor(w, idx);
|
||||||
LBackend_MarkDirty(w);
|
LBackend_MarkDirty(w);
|
||||||
|
|
||||||
if (Window_Main.SoftKeyboard && Input_TouchMode)
|
if (Window_Main.SoftKeyboardInstant)
|
||||||
LInput_OpenKeyboard(w);
|
LInput_OpenKeyboard(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,9 @@ struct _WindowData {
|
|||||||
cc_bool Inactive;
|
cc_bool Inactive;
|
||||||
/* Whether input should be ignored due to soft keyboard being open */
|
/* Whether input should be ignored due to soft keyboard being open */
|
||||||
cc_bool SoftKeyboardFocus;
|
cc_bool SoftKeyboardFocus;
|
||||||
|
/* Whether on-screen keyboard should be instantly opened when an input field is selected */
|
||||||
|
/* Otherwise, the on-screen keyboard is only opened when the input field is clicked */
|
||||||
|
cc_uint8 SoftKeyboardInstant;
|
||||||
/* Scale factors specifically for some in-game elements (e.g. chat) */
|
/* Scale factors specifically for some in-game elements (e.g. chat) */
|
||||||
/* that vary their elements based on the window dimensions */
|
/* that vary their elements based on the window dimensions */
|
||||||
float UIScaleX, UIScaleY;
|
float UIScaleX, UIScaleY;
|
||||||
|
@ -330,6 +330,7 @@ static void DoCreateWindow(void) {
|
|||||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||||
|
|
||||||
|
Window_Main.SoftKeyboardInstant = true;
|
||||||
RemakeWindowSurface();
|
RemakeWindowSurface();
|
||||||
/* always start as fullscreen */
|
/* always start as fullscreen */
|
||||||
Window_EnterFullscreen();
|
Window_EnterFullscreen();
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
static SDL_Window* win_handle;
|
static SDL_Window* win_handle;
|
||||||
#warning "Some features are missing from the SDL backend. If possible, it is recommended that you use a native windowing backend instead"
|
|
||||||
|
|
||||||
#ifdef CC_BUILD_OS2
|
#ifdef CC_BUILD_OS2
|
||||||
#define INCL_PM
|
#define INCL_PM
|
||||||
@ -76,7 +75,7 @@ void Window_Free(void) { }
|
|||||||
#include "../misc/sdl/CCIcon_SDL.h"
|
#include "../misc/sdl/CCIcon_SDL.h"
|
||||||
|
|
||||||
static void ApplyIcon(void) {
|
static void ApplyIcon(void) {
|
||||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(CCIcon_Data, CCIcon_Width, CCIcon_Height, 32, CCIcon_Pitch,
|
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom((void*)CCIcon_Data, CCIcon_Width, CCIcon_Height, 32, CCIcon_Pitch,
|
||||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
|
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
|
||||||
SDL_SetWindowIcon(win_handle, surface);
|
SDL_SetWindowIcon(win_handle, surface);
|
||||||
}
|
}
|
||||||
@ -94,6 +93,8 @@ static void DoCreateWindow(int width, int height, int flags) {
|
|||||||
Window_Main.Handle = win_handle;
|
Window_Main.Handle = win_handle;
|
||||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||||
|
|
||||||
|
Window_Main.SoftKeyboardInstant = true;
|
||||||
ApplyIcon();
|
ApplyIcon();
|
||||||
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,8 @@ static void DoCreateWindow(int width, int height, int flags) {
|
|||||||
Window_Main.Handle = win_handle;
|
Window_Main.Handle = win_handle;
|
||||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||||
|
|
||||||
|
Window_Main.SoftKeyboardInstant = true;
|
||||||
ApplyIcon();
|
ApplyIcon();
|
||||||
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
/* TODO grab using SDL_SetWindowGrab? seems to be unnecessary on Linux at least */
|
||||||
}
|
}
|
||||||
|
@ -476,6 +476,7 @@ static CGRect DoCreateWindow(void) {
|
|||||||
|
|
||||||
Window_Main.Width = bounds.size.width;
|
Window_Main.Width = bounds.size.width;
|
||||||
Window_Main.Height = bounds.size.height;
|
Window_Main.Height = bounds.size.height;
|
||||||
|
Window_Main.SoftKeyboardInstant = true;
|
||||||
|
|
||||||
NSNotificationCenter* notifications = NSNotificationCenter.defaultCenter;
|
NSNotificationCenter* notifications = NSNotificationCenter.defaultCenter;
|
||||||
[notifications addObserver:cc_controller selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
|
[notifications addObserver:cc_controller selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user