mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 23:41:09 -04:00
iOS: Now typing in onscreen keyboard for game widgets at least actually updates the in-game widget text
This commit is contained in:
parent
dac033e00b
commit
be26750b64
@ -850,6 +850,9 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
Platform_EncodeUtf8(tmp, url);
|
Platform_EncodeUtf8(tmp, url);
|
||||||
urlCF = CFStringCreateWithCString(NULL, tmp, kCFStringEncodingUTF8);
|
urlCF = CFStringCreateWithCString(NULL, tmp, kCFStringEncodingUTF8);
|
||||||
urlRef = CFURLCreateWithString(NULL, urlCF, NULL);
|
urlRef = CFURLCreateWithString(NULL, urlCF, NULL);
|
||||||
|
// TODO e.g. "http://www.example.com/skin/1 2.png" causes this to return null
|
||||||
|
// TODO release urlCF
|
||||||
|
if (!urlRef) return ERR_INVALID_DATA_URL;
|
||||||
|
|
||||||
request = CFHTTPMessageCreateRequest(NULL, verbs[req->requestType], urlRef, kCFHTTPVersion1_1);
|
request = CFHTTPMessageCreateRequest(NULL, verbs[req->requestType], urlRef, kCFHTTPVersion1_1);
|
||||||
req->meta = request;
|
req->meta = request;
|
||||||
@ -892,6 +895,7 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
if (!gotHeaders)
|
if (!gotHeaders)
|
||||||
result = ParseResponseHeaders(req, stream);
|
result = ParseResponseHeaders(req, stream);
|
||||||
|
|
||||||
|
//Thread_Sleep(1000);
|
||||||
CFRelease(request);
|
CFRelease(request);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,17 @@ static cc_bool kb_active;
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)handleKBTextChanged:(id)sender {
|
||||||
|
UITextField* src = (UITextField*)sender;
|
||||||
|
const char* str = src.text.UTF8String;
|
||||||
|
|
||||||
|
char tmpBuffer[NATIVE_STR_LEN];
|
||||||
|
cc_string tmp = String_FromArray(tmpBuffer);
|
||||||
|
String_AppendUtf8(&tmp, str, String_Length(str));
|
||||||
|
|
||||||
|
Event_RaiseString(&InputEvents.TextChanged, &tmp);
|
||||||
|
}
|
||||||
|
|
||||||
/*- (BOOL)prefersStatusBarHidden {
|
/*- (BOOL)prefersStatusBarHidden {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
@ -206,29 +217,14 @@ int main(int argc, char * argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard_GetText(cc_string* value) {
|
// iOS textfields manage ctrl+c/v
|
||||||
const char* raw;
|
void Clipboard_GetText(cc_string* value) { }
|
||||||
NSString* str;
|
void Clipboard_SetText(const cc_string* value) { }
|
||||||
|
|
||||||
str = [UIPasteboard generalPasteboard].string;
|
|
||||||
if (!str) return;
|
|
||||||
|
|
||||||
raw = str.UTF8String;
|
|
||||||
String_AppendUtf8(value, raw, String_Length(raw));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clipboard_SetText(const cc_string* value) {
|
|
||||||
char raw[NATIVE_STR_LEN];
|
|
||||||
NSString* str;
|
|
||||||
|
|
||||||
Platform_EncodeUtf8(raw, value);
|
|
||||||
str = [NSString stringWithUTF8String:raw];
|
|
||||||
[UIPasteboard generalPasteboard].string = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Window----------------------------------------------------------*
|
*---------------------------------------------------------Window----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
// no cursor on iOS
|
||||||
void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; }
|
void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; }
|
||||||
void Cursor_SetPosition(int x, int y) { }
|
void Cursor_SetPosition(int x, int y) { }
|
||||||
void Cursor_DoSetVisible(cc_bool visible) { }
|
void Cursor_DoSetVisible(cc_bool visible) { }
|
||||||
@ -307,6 +303,7 @@ static UITextField* text_input;
|
|||||||
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
|
void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) {
|
||||||
text_input = [[UITextField alloc] initWithFrame:CGRectZero];
|
text_input = [[UITextField alloc] initWithFrame:CGRectZero];
|
||||||
text_input.hidden = YES;
|
text_input.hidden = YES;
|
||||||
|
[text_input addTarget:controller action:@selector(handleKBTextChanged:) forControlEvents:UIControlEventEditingChanged];
|
||||||
|
|
||||||
LInput_SetKeyboardType(text_input, args->type);
|
LInput_SetKeyboardType(text_input, args->type);
|
||||||
LInput_SetPlaceholder(text_input, args->placeholder);
|
LInput_SetPlaceholder(text_input, args->placeholder);
|
||||||
@ -541,11 +538,11 @@ void Platform_ShareScreenshot(const cc_string* filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GetDeviceUUID(cc_string* str) {
|
void GetDeviceUUID(cc_string* str) {
|
||||||
UIDevice* device = [UIDevice currentDevice];
|
UIDevice* device = UIDevice.currentDevice;
|
||||||
NSString* string = [[device identifierForVendor] UUIDString];
|
NSString* string = [[device identifierForVendor] UUIDString];
|
||||||
|
|
||||||
// TODO avoid code duplication
|
// TODO avoid code duplication
|
||||||
const char* src = [string UTF8String];
|
const char* src = string.UTF8String;
|
||||||
String_AppendUtf8(str, src, String_Length(src));
|
String_AppendUtf8(str, src, String_Length(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,7 +639,7 @@ static NSString* cellID = @"CC_Cell";
|
|||||||
if (w == NULL) return;
|
if (w == NULL) return;
|
||||||
|
|
||||||
UITextField* src = (UITextField*)sender;
|
UITextField* src = (UITextField*)sender;
|
||||||
const char* str = [[src text] UTF8String];
|
const char* str = src.text.UTF8String;
|
||||||
struct LInput* ipt = (struct LInput*)w;
|
struct LInput* ipt = (struct LInput*)w;
|
||||||
|
|
||||||
ipt->text.length = 0;
|
ipt->text.length = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user