kou-yeung / WebGLInput

IME for Unity WebGL
MIT License
701 stars 106 forks source link

Support Login & Password Managers / Auto complete #152

Open dinkelstefan opened 1 month ago

dinkelstefan commented 1 month ago

The plugin is great for supporting browser password saving, but when saving passwords only the password is saved without the username. This is because it only keeps one HTML<input> active at the same time.

image image

Possible solution:

Thank you for your work Kou-Yeung

kou-yeung commented 1 month ago

is very hard to support autocomplete.. ( I don't know much about it i was search the sample code and read html reference. username and password need element inside at

and need submit func to save it.

so. i think you can create a custom form to overlay (default hidden) on canvas. and when you want to login. set the overlay to show at screen. and listen the submit function. when submit was called. get the text from overlay...( or redirect the result to your app

*I don't know if it will work well or not...

dinkelstefan commented 1 month ago

Thank you for your thoughts, for now saving the password is already great. I will try your idea when we experiment with password manager features in the future.

Maybe chrome will already save the username when I bind a type="email" for the username WebGLInput field

kou-yeung commented 1 month ago

now is pass the flag (bool) isPassword to javascript ( bool isPassword = input.contentType == ContentType.Password; )

maybe can conversion ContentType to string like.

string ContentTypeToInputType(ContentType type)
{
    return type switch {
        ContentType.Password => "password",
        ContentType.EmailAddress => "email",
        _ => "text"
    };
}

and pass the string to javascript from WebGLInputPlugin.WebGLInputCreate(...)

memo: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

kou-yeung commented 1 month ago

and edit WebGLInput.jslib code

if(isPassword){
    input.type = 'password';
}

↓ to input.type = UTF8ToString(contentTypeString);

maybe work..haha

kou-yeung commented 1 month ago

I don't know if it will work well or not but this change is not bad ^^

kou-yeung commented 1 month ago

tried. when set type to email Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('email') does not support selection.