diff --git a/src/Select.ts b/src/Select.ts index 168667e7..ff2c62a3 100644 --- a/src/Select.ts +++ b/src/Select.ts @@ -16,9 +16,9 @@ type Offset = { export type SelectItemsOptions = { items: string[]; backgroundColor: number | string; + width: number; + height: number; hoverColor?: number; - width?: number; - height?: number; textStyle?: Partial; radius?: number; }; @@ -193,6 +193,16 @@ export class Select extends Container this.scrollBox.y += scrollBox.offset.y ?? 0; } + this.addItems(items, selected); + } + + /** + * Adds items to the dropdown. + * @param items + * @param selected + */ + addItems(items: SelectItemsOptions, selected = 0) + { this.convertItemsToButtons(items).forEach((button, id) => { const text = button.text; @@ -216,6 +226,15 @@ export class Select extends Container }); } + /** + * Remove items from the dropdown. + * @param itemID - Item to remove (starting from 0). + */ + removeItem(itemID: number) + { + this.scrollBox.removeItem(itemID); + } + /** Toggle the select state (open if closed, closes - id open). */ toggle() {