Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 combobox 在数据的时候没有默认选中的问题 #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/src/fairygui/GComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace fgui {
if (this._selectedIndex >= this._items.length)
this._selectedIndex = this._items.length - 1;
else if (this._selectedIndex == -1)
this._selectedIndex = 0;
this.selectedIndex = 0;

this.text = this._items[this._selectedIndex];
if (this._icons && this._selectedIndex < this._icons.length)
Expand Down Expand Up @@ -354,10 +354,10 @@ namespace fgui {
str = buffer.readS();
if (str != null) {
this.text = str;
this._selectedIndex = this._items.indexOf(str);
this.selectedIndex = this._items.indexOf(str);
}
else if (this._items.length > 0) {
this._selectedIndex = 0;
this.selectedIndex = 0;
this.text = this._items[0];
}
else
Expand Down Expand Up @@ -393,7 +393,7 @@ namespace fgui {
}
this._list.resizeToFit(this._visibleItemCount);
}
this._list.selectedIndex = -1;
this._list.selectedIndex = this.selectedIndex;
this.dropdown.width = this.width;
this._list.ensureBoundsCorrect();

Expand Down
8 changes: 7 additions & 1 deletion source/src/fairygui/GLoader3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace fgui {
private _container: Laya.Sprite;
private _content: Laya.Skeleton;
private _updatingLayout: boolean;
private _aniLoaded:Laya.Handler;

public constructor() {
super();
Expand Down Expand Up @@ -188,10 +189,14 @@ namespace fgui {
}
}

public get content(): Laya.Sprite {
public get content(): Laya.Skeleton {
return this._content;
}

public set onLoader(handler: Laya.Handler) {
this._aniLoaded = handler;
}

protected loadContent(): void {
this.clearContent();

Expand Down Expand Up @@ -238,6 +243,7 @@ namespace fgui {

this._content = skeleton;
this._container.addChild(this._content);
this._aniLoaded && this._aniLoaded.runWith(this._content);
this._content.pos(anchor.x, anchor.y);
ToolSet.setColorFilter(this._content, this._color);

Expand Down