diff --git a/textfield_unix.go b/textfield_unix.go index 6535d39..0320d3b 100644 --- a/textfield_unix.go +++ b/textfield_unix.go @@ -19,6 +19,7 @@ import "C" type textfield struct { *controlSingleWidget + editable *C.GtkEditable entry *C.GtkEntry changed *event } @@ -27,6 +28,7 @@ func startNewTextField() *textfield { widget := C.gtk_entry_new() t := &textfield{ controlSingleWidget: newControlSingleWidget(widget), + editable: (*C.GtkEditable)(unsafe.Pointer(widget)), entry: (*C.GtkEntry)(unsafe.Pointer(widget)), changed: newEvent(), } @@ -74,6 +76,16 @@ func (t *textfield) Invalid(reason string) { C.gtk_widget_error_bell(t.widget) } +// note that the property here is editable, which is the opposite of read-only + +func (t *textfield) ReadOnly() bool { + return !fromgbool(C.gtk_editable_get_editable(t.editable)) +} + +func (t *textfield) SetReadOnly(readonly bool) { + C.gtk_editable_set_editable(t.editable, togbool(!readonly)) +} + //export textfieldChanged func textfieldChanged(editable *C.GtkEditable, data C.gpointer) { t := (*textfield)(unsafe.Pointer(data))