The mobileKeyboard module provides a JavaScript interface for controlling the WeChat Mini Game mobile keyboard from within a Unity/Tuanjie engine environment. It wraps wx.showKeyboard and related WeChat APIs to allow the engine to manage text input, character limits, and keyboard visibility.
Key Capabilities
- Show Keyboard: Display the keyboard with specific configurations like multiline support, character limits, and placeholder text.
- Text Management: Retrieve the current text content or set new text values.
- Visibility Control: Programmatically hide the keyboard.
- Status Monitoring: Check if the keyboard is currently visible or has been dismissed.
Note: This module relies on FrameworkData (passed during _JS_MobileKeyboard_Show) to handle string conversions between JavaScript and the engine's memory (UTF8/HEAP32).
// Example conceptual usage via the exported interface
import mobileKeyboard from './mobileKeyboard/index.js';
// Show the keyboard
mobileKeyboard._JS_MobileKeyboard_Show(
textPtr, // Pointer to UTF8 string
type, // keyboardType
true, // autocorrection
false, // multiline
false, // secure
false, // alert
placeholder, // placeholder
140, // characterLimit
frameworkData // The engine's FrameworkData object
);
// Get the current text
const textLen = mobileKeyboard._JS_MobileKeyboard_GetText(buffer, bufferSize);
// Hide the keyboard
mobileKeyboard._JS_MobileKeyboard_Hide(true); // true for delayed hide