Skip to content

Commit

Permalink
fix keyboard with textarea associations in user widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 21, 2024
1 parent cf53658 commit 4700bf2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 60 deletions.
126 changes: 67 additions & 59 deletions packages/project-editor/lvgl/identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,78 +80,74 @@ export class LVGLIdentifiers {
return styles;
}

get widgetIdentifiers(): {
global: LVGLIdentifier[];
userWidget: Map<Page, LVGLIdentifier[]>;
} {
const result = {
global: [],
userWidget: new Map()
};

function enumIdentifiers(
page: Page,
identifiers: LVGLIdentifier[],
prefix: string
) {
page._lvglWidgets.forEach(widget => {
let identifierName;
enumIdentifiers(page: Page, identifiers: LVGLIdentifier[], prefix: string) {
page._lvglWidgets.forEach(widget => {
let identifierName;

if (widget instanceof ProjectEditor.LVGLScreenWidgetClass) {
identifierName = getName(
"",
page.name,
NamingConvention.UnderscoreLowerCase
);
} else {
if (!widget.identifier) {
return;
}

if (widget instanceof ProjectEditor.LVGLScreenWidgetClass) {
identifierName = getName(
identifierName =
prefix +
getName(
"",
page.name,
widget.identifier,
NamingConvention.UnderscoreLowerCase
);
} else {
if (!widget.identifier) {
return;
}

identifierName =
prefix +
getName(
"",
widget.identifier,
NamingConvention.UnderscoreLowerCase
);
}
}

if (!identifierName) {
return;
}
if (!identifierName) {
return;
}

const identifier = identifiers.find(
identifier => identifier.identifier == identifierName
);
if (identifier) {
identifier.widgets.push(widget);
} else {
identifiers.push({
identifier: identifierName,
widgets: [widget]
});
}
const identifier = identifiers.find(
identifier => identifier.identifier == identifierName
);
if (identifier) {
identifier.widgets.push(widget);
} else {
identifiers.push({
identifier: identifierName,
widgets: [widget]
});
}

if (widget instanceof ProjectEditor.LVGLUserWidgetWidgetClass) {
if (widget.userWidgetPage) {
enumIdentifiers(
widget.userWidgetPage,
identifiers,
identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
);
}
if (widget instanceof ProjectEditor.LVGLUserWidgetWidgetClass) {
if (widget.userWidgetPage) {
this.enumIdentifiers(
widget.userWidgetPage,
identifiers,
identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
);
}
});
}
}
});
}

get widgetIdentifiers(): {
global: LVGLIdentifier[];
userWidget: Map<Page, LVGLIdentifier[]>;
} {
const result = {
global: [],
userWidget: new Map()
};

for (const page of this.pages) {
if (page.isUsedAsUserWidget) {
const identifiers: LVGLIdentifier[] = [];
enumIdentifiers(page, identifiers, "");
this.enumIdentifiers(page, identifiers, "");
result.userWidget.set(page, identifiers);
} else {
enumIdentifiers(page, result.global, "");
this.enumIdentifiers(page, result.global, "");
}
}

Expand All @@ -169,7 +165,19 @@ export class LVGLIdentifiers {
flow: Flow,
displayName: string
): LVGLIdentifier | undefined {
const identifiers = this.getIdentifiersVisibleFromFlow(flow);
let identifiers = this.getIdentifiersVisibleFromFlow(flow);

if (!identifiers) {
if (
flow instanceof ProjectEditor.PageClass &&
flow._lvglUserWidgetOfPageCopy
) {
identifiers = [];
this.enumIdentifiers(flow, identifiers, "");
} else {
return undefined;
}
}

return identifiers.find(
lvglIdentifier => lvglIdentifier.identifier == displayName
Expand Down
1 change: 0 additions & 1 deletion packages/project-editor/lvgl/widgets/UserWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ export class LVGLUserWidgetWidget extends LVGLWidget {
const widgetStartIndex =
assets.lvglBuild.getWidgetObjectIndex(this) + 1;

console.log(this.identifier, widgetStartIndex);
dataBuffer.writeInt32(widgetStartIndex);
} else {
// flowIndex
Expand Down

0 comments on commit 4700bf2

Please sign in to comment.