give widgets a name

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@22 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-28 10:06:00 +00:00
parent 052b10d097
commit 6ffbb575e6
4 changed files with 10 additions and 3 deletions

View File

@@ -11,9 +11,12 @@ static void llhandler(MilskoLL handle) {
Dispatch(h, draw);
}
MilskoWidget MilskoCreateWidget(MilskoClass class, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
MilskoWidget h = malloc(sizeof(*h));
h->name = malloc(strlen(name) + 1);
strcpy(h->name, name);
h->parent = parent;
h->children = NULL;
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
@@ -40,6 +43,8 @@ void MilskoDestroyWidget(MilskoWidget handle) {
Dispatch(handle, destroy);
free(handle->name);
if(handle->children != NULL) {
for(i = 0; i < arrlen(handle->children); i++) {
if(handle->children[i] == handle) {