Skip to content

Commit 4700bf2

Browse files
committed
fix keyboard with textarea associations in user widgets
1 parent cf53658 commit 4700bf2

File tree

2 files changed

+67
-60
lines changed

2 files changed

+67
-60
lines changed

packages/project-editor/lvgl/identifiers.ts

+67-59
Original file line numberDiff line numberDiff line change
@@ -80,78 +80,74 @@ export class LVGLIdentifiers {
8080
return styles;
8181
}
8282

83-
get widgetIdentifiers(): {
84-
global: LVGLIdentifier[];
85-
userWidget: Map<Page, LVGLIdentifier[]>;
86-
} {
87-
const result = {
88-
global: [],
89-
userWidget: new Map()
90-
};
91-
92-
function enumIdentifiers(
93-
page: Page,
94-
identifiers: LVGLIdentifier[],
95-
prefix: string
96-
) {
97-
page._lvglWidgets.forEach(widget => {
98-
let identifierName;
83+
enumIdentifiers(page: Page, identifiers: LVGLIdentifier[], prefix: string) {
84+
page._lvglWidgets.forEach(widget => {
85+
let identifierName;
86+
87+
if (widget instanceof ProjectEditor.LVGLScreenWidgetClass) {
88+
identifierName = getName(
89+
"",
90+
page.name,
91+
NamingConvention.UnderscoreLowerCase
92+
);
93+
} else {
94+
if (!widget.identifier) {
95+
return;
96+
}
9997

100-
if (widget instanceof ProjectEditor.LVGLScreenWidgetClass) {
101-
identifierName = getName(
98+
identifierName =
99+
prefix +
100+
getName(
102101
"",
103-
page.name,
102+
widget.identifier,
104103
NamingConvention.UnderscoreLowerCase
105104
);
106-
} else {
107-
if (!widget.identifier) {
108-
return;
109-
}
110-
111-
identifierName =
112-
prefix +
113-
getName(
114-
"",
115-
widget.identifier,
116-
NamingConvention.UnderscoreLowerCase
117-
);
118-
}
105+
}
119106

120-
if (!identifierName) {
121-
return;
122-
}
107+
if (!identifierName) {
108+
return;
109+
}
123110

124-
const identifier = identifiers.find(
125-
identifier => identifier.identifier == identifierName
126-
);
127-
if (identifier) {
128-
identifier.widgets.push(widget);
129-
} else {
130-
identifiers.push({
131-
identifier: identifierName,
132-
widgets: [widget]
133-
});
134-
}
111+
const identifier = identifiers.find(
112+
identifier => identifier.identifier == identifierName
113+
);
114+
if (identifier) {
115+
identifier.widgets.push(widget);
116+
} else {
117+
identifiers.push({
118+
identifier: identifierName,
119+
widgets: [widget]
120+
});
121+
}
135122

136-
if (widget instanceof ProjectEditor.LVGLUserWidgetWidgetClass) {
137-
if (widget.userWidgetPage) {
138-
enumIdentifiers(
139-
widget.userWidgetPage,
140-
identifiers,
141-
identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
142-
);
143-
}
123+
if (widget instanceof ProjectEditor.LVGLUserWidgetWidgetClass) {
124+
if (widget.userWidgetPage) {
125+
this.enumIdentifiers(
126+
widget.userWidgetPage,
127+
identifiers,
128+
identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
129+
);
144130
}
145-
});
146-
}
131+
}
132+
});
133+
}
134+
135+
get widgetIdentifiers(): {
136+
global: LVGLIdentifier[];
137+
userWidget: Map<Page, LVGLIdentifier[]>;
138+
} {
139+
const result = {
140+
global: [],
141+
userWidget: new Map()
142+
};
147143

148144
for (const page of this.pages) {
149145
if (page.isUsedAsUserWidget) {
150146
const identifiers: LVGLIdentifier[] = [];
151-
enumIdentifiers(page, identifiers, "");
147+
this.enumIdentifiers(page, identifiers, "");
152148
result.userWidget.set(page, identifiers);
153149
} else {
154-
enumIdentifiers(page, result.global, "");
150+
this.enumIdentifiers(page, result.global, "");
155151
}
156152
}
157153

@@ -169,7 +165,19 @@ export class LVGLIdentifiers {
169165
flow: Flow,
170166
displayName: string
171167
): LVGLIdentifier | undefined {
172-
const identifiers = this.getIdentifiersVisibleFromFlow(flow);
168+
let identifiers = this.getIdentifiersVisibleFromFlow(flow);
169+
170+
if (!identifiers) {
171+
if (
172+
flow instanceof ProjectEditor.PageClass &&
173+
flow._lvglUserWidgetOfPageCopy
174+
) {
175+
identifiers = [];
176+
this.enumIdentifiers(flow, identifiers, "");
177+
} else {
178+
return undefined;
179+
}
180+
}
173181

174182
return identifiers.find(
175183
lvglIdentifier => lvglIdentifier.identifier == displayName

packages/project-editor/lvgl/widgets/UserWidget.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ export class LVGLUserWidgetWidget extends LVGLWidget {
615615
const widgetStartIndex =
616616
assets.lvglBuild.getWidgetObjectIndex(this) + 1;
617617

618-
console.log(this.identifier, widgetStartIndex);
619618
dataBuffer.writeInt32(widgetStartIndex);
620619
} else {
621620
// flowIndex

0 commit comments

Comments
 (0)