ui/gtk/text.c

changeset 100
d2bd73d28ff1
parent 97
5a3d27b8e6b0
equal deleted inserted replaced
99:b9767cb5b06b 100:d2bd73d28ff1
549 UiTextField *uitext = malloc(sizeof(UiTextField)); 549 UiTextField *uitext = malloc(sizeof(UiTextField));
550 uitext->obj = obj; 550 uitext->obj = obj;
551 uitext->var = var; 551 uitext->var = var;
552 uitext->onchange = args.onchange; 552 uitext->onchange = args.onchange;
553 uitext->onchangedata = args.onchangedata; 553 uitext->onchangedata = args.onchangedata;
554 uitext->onactivate = args.onactivate;
555 uitext->onactivatedata = args.onactivatedata;
554 556
555 g_signal_connect( 557 g_signal_connect(
556 textfield, 558 textfield,
557 "destroy", 559 "destroy",
558 G_CALLBACK(ui_textfield_destroy), 560 G_CALLBACK(ui_textfield_destroy),
597 "changed", 599 "changed",
598 G_CALLBACK(ui_textfield_changed), 600 G_CALLBACK(ui_textfield_changed),
599 uitext); 601 uitext);
600 } 602 }
601 603
604 if(args.onactivate) {
605 g_signal_connect(
606 textfield,
607 "activate",
608 G_CALLBACK(ui_textfield_activate),
609 uitext);
610 }
611
602 return textfield; 612 return textfield;
603 } 613 }
604 614
605 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) { 615 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) {
606 return create_textfield(obj, FALSE, FALSE, args); 616 return create_textfield(obj, FALSE, FALSE, args);
636 if(textfield->var) { 646 if(textfield->var) {
637 ui_notify_evt(value->observers, &e); 647 ui_notify_evt(value->observers, &e);
638 } 648 }
639 } 649 }
640 650
651 void ui_textfield_activate(GtkEntry* self, UiTextField *textfield) {
652 if(textfield->onactivate) {
653 UiEvent e;
654 e.obj = textfield->obj;
655 e.window = e.obj->window;
656 e.document = textfield->obj->ctx->document;
657 e.eventdata = NULL;
658 e.intval = 0;
659 textfield->onactivate(&e, textfield->onactivatedata);
660 }
661 }
641 662
642 char* ui_textfield_get(UiString *str) { 663 char* ui_textfield_get(UiString *str) {
643 if(str->value.ptr) { 664 if(str->value.ptr) {
644 str->value.free(str->value.ptr); 665 str->value.free(str->value.ptr);
645 } 666 }

mercurial