diff --git a/spx-gui/src/components/community/user/UserItem.vue b/spx-gui/src/components/community/user/UserItem.vue
index 481cdfc03..ba61ae795 100644
--- a/spx-gui/src/components/community/user/UserItem.vue
+++ b/spx-gui/src/components/community/user/UserItem.vue
@@ -20,7 +20,7 @@ const userRoute = computed(() => getUserPageRoute(props.user.username))
{{ user.displayName }}
-
+
diff --git a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts
index c9a34d14f..ca8b4ebe2 100644
--- a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts
+++ b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts
@@ -188,7 +188,7 @@ export const gameCategory: ToolCategory = {
},
{
label: { en: 'Others', zh: '其他' },
- tools: [spx.rand, gop.println]
+ tools: [spx.rand, gop.println, spx.getWidget]
}
]
}
@@ -253,6 +253,23 @@ export function getVariableCategory(project: Project): ToolCategory {
})
})
+ groups.push({
+ label: { en: 'Widgets', zh: '控件' },
+ tools: project.stage.widgets.map((widget) => {
+ const keyword = `"${widget.name}"`
+ return {
+ type: ToolType.variable,
+ target: ToolContext.all,
+ keyword,
+ desc: { en: `Widget "${widget.name}"`, zh: `控件 ${widget.name}` },
+ usage: {
+ sample: keyword,
+ insertText: keyword
+ }
+ }
+ })
+ })
+
if (project.selectedSprite != null) {
groups.push({
label: {
diff --git a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts
index 00b533686..f2ceb4b19 100644
--- a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts
+++ b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts
@@ -974,6 +974,20 @@ export const exit: Tool = {
}
}
+export const getWidget: Tool = {
+ type: ToolType.function,
+ callEffect: ToolCallEffect.read,
+ target: ToolContext.all,
+ keyword: 'getWidget',
+ desc: { en: 'Get the widget by given name', zh: '通过指定名称获取控件' },
+ usage: {
+ sample: 'getWidget(Monitor, "monitor1")',
+ insertText: 'getWidget(${1:Monitor}, ${2:name})'
+ }
+}
+
+// TODO: definition for widget methods
+
function defineConst(name: string, desc: LocaleMessage): Tool {
name = name[0].toUpperCase() + name.slice(1) // it's strange, but required
return {
diff --git a/spx-gui/src/components/editor/preview/EditorPreview.vue b/spx-gui/src/components/editor/preview/EditorPreview.vue
index 27e5ff655..138589f05 100644
--- a/spx-gui/src/components/editor/preview/EditorPreview.vue
+++ b/spx-gui/src/components/editor/preview/EditorPreview.vue
@@ -19,15 +19,19 @@
diff --git a/spx-gui/src/components/ui/modal/UIDropdownModal.vue b/spx-gui/src/components/ui/modal/UIDropdownModal.vue
index 7655abec2..07d67d43d 100644
--- a/spx-gui/src/components/ui/modal/UIDropdownModal.vue
+++ b/spx-gui/src/components/ui/modal/UIDropdownModal.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/spx-gui/src/widgets/spx-runner/SpxRunner.ce.vue b/spx-gui/src/widgets/spx-runner/SpxRunner.ce.vue
index 338ec8da0..a06b319dd 100644
--- a/spx-gui/src/widgets/spx-runner/SpxRunner.ce.vue
+++ b/spx-gui/src/widgets/spx-runner/SpxRunner.ce.vue
@@ -29,8 +29,8 @@