feat: Implement text field component with keyboard input handling Added a new TextField component to the UI framework, allowing for user input with keyboard support. Integrated keyboard event handling in the Windows backend to process key inputs and modifiers. Enhanced the runtime state to manage focus on text fields and handle keyboard events accordingly. Updated the engine to support text field rendering and layout. Created tests for keyboard input and text field functionality in both web and Windows environments. Introduced a new Todo application example demonstrating the use of the text field component.
feat: Implement text field component with keyboard input handling
MoUI 是一个 MoonBit GUI 框架原型。当前仓库同时包含 macOS native 原型、Windows native 试验路径,以及 JS target 的 web 示例;底层复用 Milky2018/window 的窗口事件循环与 Milky2018/wgpu_mbt 的图形能力。
Milky2018/window
Milky2018/wgpu_mbt
ViewNode
label
button
row
column
padding
examples/counter
examples/counter_windows
examples/counter_web
core/ 平台无关核心模型 views/ 基础视图构造器 render/ 渲染器 facade 与绘制批处理 backend/ native / web 后端适配 facade examples/counter/ macOS native Counter 示例 examples/counter_windows/ Windows native Counter 示例 examples/counter_web/ JS target Counter 示例
moon
PATH
ucrt64
export MBT_WGPU_NATIVE_ROOT=/Users/zc/Downloads/wgpu-macos-aarch64-release moon check --target native moon test --target native moon fmt moon info moon run examples/counter --target native
Milky2018/wgpu_mbt 按上游 README 使用默认 static 模式;下游包只需要用 "Milky2018/wgpu_mbt" @wgpu 导入,不需要手写额外 link flags。如果本机无法访问 GitHub release 下载器,可将 MBT_WGPU_NATIVE_ROOT 指向已解压的官方 wgpu-macos-aarch64-release 目录。
"Milky2018/wgpu_mbt" @wgpu
MBT_WGPU_NATIVE_ROOT
wgpu-macos-aarch64-release
Milky2018/window 不支持 Windows 需要 clone git@github.com:wzzc-dev/window.git 到 .local_repos 使用本地依赖
先安装 MSYS2,并确保存在 C:\msys64\ucrt64\bin。然后安装 UCRT64 编译链和 Vulkan 依赖:
C:\msys64\ucrt64\bin
C:\msys64\usr\bin\pacman.exe -S --needed --noconfirm ` mingw-w64-ucrt-x86_64-gcc ` mingw-w64-ucrt-x86_64-vulkan-loader ` mingw-w64-ucrt-x86_64-vulkan-headers
说明:
mingw-w64-ucrt-x86_64-gcc
x86_64-w64-mingw32-gcc
g++
mingw-w64-ucrt-x86_64-vulkan-loader
vulkan-1.dll
mingw-w64-ucrt-x86_64-vulkan-headers
wgpu-native
按 Milky2018/wgpu_mbt 当前 pinned 版本 v27.0.4.0,下载 Windows x64 GNU 包:
v27.0.4.0
wgpu-windows-x86_64-gnu-release.zip
gfx-rs/wgpu-native@v27.0.4.0
解压后推荐放到仓库内:
.local_deps/wgpu-native/v27.0.4.0/wgpu-windows-x86_64-gnu-release
也可以放到别的稳定目录,再通过脚本参数 -WgpuNativeRoot 指定。
-WgpuNativeRoot
powershell -ExecutionPolicy Bypass -File .\scripts\windows\counter_windows_static.ps1 -BuildOnly
powershell -ExecutionPolicy Bypass -File .\scripts\windows\counter_windows_static.ps1
这个脚本会自动:
CC=x86_64-w64-mingw32-gcc
CXX=x86_64-w64-mingw32-g++
MBT_WGPU_LINK_MODE
MBT_WGPU_NATIVE_LIB
MBT_WGPU_VULKAN_LIB
如果 wgpu-native 没放在默认目录,可显式传入:
powershell -ExecutionPolicy Bypass -File .\scripts\windows\counter_windows_static.ps1 ` -BuildOnly ` -WgpuNativeRoot C:\path\to\wgpu-windows-x86_64-gnu-release
等价的手动命令如下:
$env:PATH = "C:\msys64\ucrt64\bin;$env:PATH" $env:CC = "x86_64-w64-mingw32-gcc" $env:CXX = "x86_64-w64-mingw32-g++" $env:MBT_WGPU_NATIVE_ROOT = "$PWD\.local_deps\wgpu-native\v27.0.4.0\wgpu-windows-x86_64-gnu-release" Remove-Item Env:MBT_WGPU_LINK_MODE -ErrorAction SilentlyContinue Remove-Item Env:MBT_WGPU_NATIVE_LIB -ErrorAction SilentlyContinue Remove-Item Env:MBT_WGPU_VULKAN_LIB -ErrorAction SilentlyContinue moon build examples/counter_windows --target native .\_build\native\debug\build\examples\counter_windows\counter_windows.exe
运行时如果提示缺少 libwinpthread-1.dll 或 vulkan-1.dll,通常是因为当前 shell 没带上 C:\msys64\ucrt64\bin;直接通过上面的脚本启动即可。
libwinpthread-1.dll
moon build examples/counter_web --target js Copy-Item examples/counter_web/bootstrap.js _build\js\debug\build\examples\counter_web\bootstrap.js -Force Copy-Item examples/counter_web/index.html _build\js\debug\build\examples\counter_web\index.html -Force python -m http.server 8080 --bind 127.0.0.1 --directory _build\js\debug\build\examples\counter_web\
Windows native text rendering uses the existing MoonBit packages below:
bikallem/freetype
moonbit-community/harfbuzz
moonbitlang/x
The renderer loads system fonts from Windows instead of bundling font assets:
C:\Windows\Fonts\segoeui.ttf C:\Windows\Fonts\segoeuib.ttf
Install the native build/runtime dependencies with MSYS2 UCRT64:
Use the static Windows GNU wgpu-native release expected by the helper script:
.local_deps\wgpu-native\v27.0.4.0\wgpu-windows-x86_64-gnu-release
Build only:
Build and run:
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
MoUI
MoUI 是一个 MoonBit GUI 框架原型。当前仓库同时包含 macOS native 原型、Windows native 试验路径,以及 JS target 的 web 示例;底层复用
Milky2018/window的窗口事件循环与Milky2018/wgpu_mbt的图形能力。首版范围
ViewNode视图树。label、button、row、column、padding。examples/counter、examples/counter_windows、examples/counter_web作为不同目标的示例入口。包结构
环境准备
moon在PATH中。ucrt64工具链。macOS native 验证
Milky2018/wgpu_mbt按上游 README 使用默认 static 模式;下游包只需要用"Milky2018/wgpu_mbt" @wgpu导入,不需要手写额外 link flags。如果本机无法访问 GitHub release 下载器,可将MBT_WGPU_NATIVE_ROOT指向已解压的官方wgpu-macos-aarch64-release目录。Windows native(静态 wgpu,MSYS2 / MinGW)
1. 安装依赖
先安装 MSYS2,并确保存在
C:\msys64\ucrt64\bin。然后安装 UCRT64 编译链和 Vulkan 依赖:说明:
mingw-w64-ucrt-x86_64-gcc提供x86_64-w64-mingw32-gcc/g++mingw-w64-ucrt-x86_64-vulkan-loader提供vulkan-1.dll与链接库mingw-w64-ucrt-x86_64-vulkan-headers提供 Vulkan 头文件2. 准备
wgpu-native静态库按
Milky2018/wgpu_mbt当前 pinned 版本v27.0.4.0,下载 Windows x64 GNU 包:wgpu-windows-x86_64-gnu-release.zipgfx-rs/wgpu-native@v27.0.4.0解压后推荐放到仓库内:
也可以放到别的稳定目录,再通过脚本参数
-WgpuNativeRoot指定。3. 只构建
4. 构建并运行
这个脚本会自动:
C:\msys64\ucrt64\bin追加到当前进程PATHCC=x86_64-w64-mingw32-gccCXX=x86_64-w64-mingw32-g++MBT_WGPU_NATIVE_ROOT指向静态库 release 根目录MBT_WGPU_LINK_MODE、MBT_WGPU_NATIVE_LIB、MBT_WGPU_VULKAN_LIB等动态模式残留变量如果
wgpu-native没放在默认目录,可显式传入:等价的手动命令如下:
运行时如果提示缺少
libwinpthread-1.dll或vulkan-1.dll,通常是因为当前 shell 没带上C:\msys64\ucrt64\bin;直接通过上面的脚本启动即可。web 示例
Windows native text rendering dependencies
Windows native text rendering uses the existing MoonBit packages below:
bikallem/freetype: glyph bitmap rasterization.moonbit-community/harfbuzz: text shaping.moonbitlang/x: filesystem access for loading system font files.The renderer loads system fonts from Windows instead of bundling font assets:
Install the native build/runtime dependencies with MSYS2 UCRT64:
Use the static Windows GNU
wgpu-nativerelease expected by the helper script:Build only:
Build and run: