From 372cbf044d70b2322b85357ee6aaebe625b34964 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 6 May 2015 22:09:10 -0400 Subject: [PATCH] Added uiEntryReadOnly() and uiEntrySetReadOnly(). --- test/page2.c | 16 ++++++++++------ ui.idl | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/page2.c b/test/page2.c index dd649f25..0cf3ab69 100644 --- a/test/page2.c +++ b/test/page2.c @@ -50,12 +50,12 @@ static void openAnotherWindow(uiButton *b, void *data) SHED(enable, Enable) SHED(disable, Disable) -static void setLabelText(uiEntry *e, void *data) +static void echoReadOnlyText(uiEntry *e, void *data) { char *text; text = uiEntryText(e); - uiLabelSetText(uiLabel(data), text); + uiEntrySetText(uiEntry(data), text); uiFreeText(text); } @@ -70,7 +70,7 @@ uiBox *makePage2(void) uiBox *innerhbox3; uiTab *disabledTab; uiEntry *entry; - uiLabel *entrylabel; + uiEntry *readonly; page2 = newVerticalBox(); @@ -153,10 +153,14 @@ uiBox *makePage2(void) uiBoxAppend(page2, uiControl(disabledTab), 1); entry = uiNewEntry(); - entrylabel = uiNewLabel(""); - uiEntryOnChanged(entry, setLabelText, entrylabel); + readonly = uiNewEntry(); + uiEntryOnChanged(entry, echoReadOnlyText, readonly); + uiEntrySetText(readonly, "If you can see this, uiEntryReadOnly() isn't working properly."); + uiEntrySetReadOnly(readonly), 1); + if (uiEntryReadOnly(readonly)) + uiEntrySetText(readonly, ""); uiBoxAppend(page2, uiControl(entry), 0); - uiBoxAppend(page2, uiControl(entrylabel), 0); + uiBoxAppend(page2, uiControl(readonly), 0); return page2; } diff --git a/ui.idl b/ui.idl index 4603616c..cb631145 100644 --- a/ui.idl +++ b/ui.idl @@ -84,6 +84,8 @@ interface Entry from Control { func Text(void) *char; func SetText(text *const char); func OnChanged(f *func(e *Entry, data *void), data *void); + func ReadOnly(void) int; + func SetReadOnly(readonly int); }; func NewEntry(void) *Entry;